perm filename CH.RBA[NET,GUE] blob sn#019416 filedate 1973-01-08 generic text, type T, neo UTF8
TITLE CHESS C

.XCREF P

DEC==0
DBG==1	;0 TO FLUSH SELF CHECKING AND SOME DEBUGGING ROUTINES
KILLH==0	;0 NO KILL HEURISTIC 1 KILL HEURISTIC
HSCOD==1	;HASH CODE FEATURE
BOOK==1	;INCLUDE CODE FOR BOOK OPENINGS
UTAPE==1	;INCLUDE UTAPE ROUTINES
DSPLY==1	;INCLUDE DISPLAY (TS OR NO)
DECTS==0

TS==1	;0 FOR NON TS
IFE TS,RELOCATABLE
IFN TS,[DEC==1
UTAPE==1]

IFN DECTS,[
DEC==1
TS==0
DSPLY==0
DECASA==140
]

LOC 100

IFE DEC,[
IRPS A,,PILPT LINEPOS LPTWAT
	.GLOBAL A
	.LIBRQ A
	TERMIN
IRPS A,,A P LPTCHN LPTBSZ
	.GLOBAL A
	TERMIN
]

ZR=0
A=1
B=2
C=3
D=4
T=5
TT=6
R=7
Q=10
I=11
J=12
S=13
T1=14
T2=15
W=16
P"=17

;CONSTRAINT TABLE

;WD0
; RH LINK 4.9-4.7 CODE 0 DEFENSE 1 MATE STOPPAGE 2 BACK RANK HACK (SQ IS SQ HE MOVES TO)
SPINSQ==320700	;SQUARE INVOLVED
NSTRB==100,,	;IF SET IN DPIGT, MEANS CONSTRAINT NOT TO BE CONSIDERED STRONG THREAT
DFCNB==100,,	;IF SET IN IDEF ENTRY, INDICATES THIS DEF IS INITIALLY A CONSTRAINT
			;AND IS IN SPINT LIST
SPINVL==2200	;CALC LOSS 
SPCCN==220600	;CONSTRAINED PC

;WD1
SPNLK==2200	;RH LINK OR 0
SPINCP==220600	;PC CAUSING CONSTRAINT IF ONE, ELSE 0

NWCN==2	;# WDS PER ENTRY

;THREAT TABLE ENTRY

NWTHE==2	;# WDS IN THREAT ENTRY

;WD1
THRTP==360600	;HIS PIECE POSING THREAT
THRTS==270700	;SQUARE TO MOVE TO
THRCD==240300	;THREAT CODE 0=CAPTURE 1=MULT ATTACK 
		;2=MATE 3=STRONG ATTACK (ON PINNED OR TRAPPED PIECE) 
		;4 TRADE THREATNED WHEN BEHIND OR MINOR EXCHANGE
		;5 PUSH PASSED PAWN
THRRL==230100	;3.2 ONE OF SEVERAL RELATED CAPTURE THREATS TO CAPTURE SAME PIECE
BTHRRL==2
THANS==220100	;SET AT THAN IF THREAT ANSWERED
BTHANS==1
THAUXP==140600	; IF .NE. 0 INDEX TO AUX THREAT DIS TABLE
THRVAL==1400	;APPARENT GAIN FROM EXECUTION OF THREAT

;WD2 LH 
THSCF==400000	;1 IF ONLY ONE WAY FOR HIM TO TAKE THIS THREAT
THSTR==200000	;STRONG (PIECE PINNED OR CONSTRAINED)
THQTH==100000	;QUESTIONABLE IF THIS THREAT REALLY EXISTS
			;IE COMPUTE ANS, ETC, BUT DONT DOCK MOVES FOR NOT
			;ANSWERING UNTIL CONFIRMED ETC
;WD2 RH TEMPO VALUE

LTHAUXT==63	;MUST BE ADDRESSED BY THAUXP

THAUXT==.-1	;AUX THREAT DESC TABLE
	BLOCK LTHAUXT	;4.9 END OF ENTRIES DESC PARTICULAR MOVE
THAXCD==400300	;4.8-4.5 AUX DESC CODE 0 SECONDARY ATTACKER
THAXPC==320600	;PIECE INVOLVED
THAXV==1400	;AMT THREAT REDUCED IF PIECE CAPTURED OR BLOCKED


ATHRP:	0	;ALLOCATOR POINTER TO AUX THREAT TBL

;MVDST ENTRY
NWMVE==2	;# WDS IN MOVE TABLE DESC ENTRY
;WD1
;4.9 USED FOR MARKED OUT BIT
MVDSFT==11.	;SHIFT TO MOVE MVDCAP ETC INTO MVDCD (+SWAP)
MVDCD=350600	;DESCRIPTION CODE  0 CAPT. LOSS OR GAIN;  1 DEFENSE 2 BLOCKED DEFENSE
	;3 ABANDONMENT 4 PIN 5 ATTACK 6 ATTACK ON SQUARE NEAR K 7 SUPPORT OF OTHER ATTACK
	;10 PUSH PASSED P 11 BLOCK PASSED P 12 BLOCKING HIS DEFENSE
	;13 CAPTURE CONSTRAINED PIECE 14 MVING INTO PRISE CALC LOSS
	;15 UNBLOCKING HIS ATTACK 16 SETTING UP DISCOVERY
	;17 RELEASING PIN ON HIM 20 RELEASING ATTACK ON PIN
	;21 HOLDING PIN 22 ATT PINNED PIECE 23 HELPING TO RELIEVE
	;PIN BY DEFENDING BASE PIECE 24 PAWN BREAK
	;25 RELEASING ATTACK ON HIS PIECE 26 RELEASING PIN
	;27 GAINING CONTROL OF SQUARE
	;30 TOO EARLY TO MOVE THIS PC W/O POSITIVE REASON
	;31 INITIAL DEVELOPING MOVE 32 PINNING CONSTRAINED PC
	;33 MVING THREATNED PIECE 34 UNBLOCKING PASSED P
	;35 RELEASING ATT ON SQ NEAR K 36 RLSING DEF
	;37 INTERPOSING
MVSAB==200,,	;STRONG THREAT BIT ADD TO SAGAIN INSTEAD OF USUAL
MVDAB==400,,	;DOUBLE ATTACK MARKER  (SET IN ATT ENTRY IF A DISCOVERY ALSO
			;ATTACKS SAME SQ)
MVBDAB==310100	;BIT ASSOC WITH ABOVE
MVWAB==1000,,	;WEAK ATTACK BIT (ADD TO PGAIN)
MVATB==2000,,	;SET IF "ATTACKING THRU"
MVDSQ=220700	;SQUARE
;2.8,2.9 FREE
MVDPC2=120600	;OUR PIECE MOVING
MVDDIR==70300	;DIRECTION OF ATTACK
MVDDIS=60100	;ASSOCIATED WITH DISCOVERY
MVDDIB==100	;BIT ASSOC WITH ABOVE
MVDPC=600	;PIECE BLOCKED/UNBLOCKED IF DISCOVERED OR LEFT LOOSE IF CONSTRAINT BROKEN

;WD2 RH ASSOCIATED VALUE

MVDCAP==0	;CAPT
MVDDEF==1	;DEFENSE
MVDBDF==2	;BLOCKING OUR DEFENSE
MVDABN==3	;BREAKING CONSTRAINT
MVDPIN==4	;MVDSQ HAS BASE SQUARE MVDPC PIECE MAYBE PINNED
MVDAT==5	;ATTACK WD2 HAS THREATNED CALC GAIN
MVDDSQ==6	;DENYING SQUARE
MVDPPP==10	;PUSH PASSED P
MVDBPP==11	;BLOCK PASSED P
MVBHD==12	;WD2 HAS THREATNED GAIN
MVCCP==13	;CAPT CONSTRAINED PIECE
MVEP==14	;MOVING INTO PRISE
MVDHA==15	;DISCOVERING ATTACK BY HIM
MVDSD==16	;SETTING UP POSSIBLE DISCOVERY BY ATTACKING OUR GUY
		;WHO COULD MOVE AWAY EXPOSING ATTACK ON HIM
		;MVDPC => PIECE MAYBE DISCOVERED ON
		;MVDPC2 => OUR GUY TO MOVE TO EFFECT DISCOVERY
		;MVDSQ => SQUARE OF OUR GUY TO MOVE OUT OF WAY 
		;(HIS GUY MAY BE ON SQUARE NOW IF MOVE IS CAPTURE)
		;VAL => VAL IF DISCOVERY WERE ATTACK
MVDRPN==17	;RELEASING PIN ON HIS PC AT SQ BY MOVING PINNING PC
MVDRPA==20	;RELEASING ATT ON HIS PINNED  P AT SQ
MVDHPN==21	;HOLDING PIN (NEGATES MVDRPN)
MVDAPP==22	;ATTACKING HIS PINNED PIECE
MVDDBP==23	;DEFENDING BASE PIECE
MVDPWB==24	;PAWN BREAK
MVDRLA==25	;RELEASING ATTACK ON HIS PIECE
MVDROP==26	;RELEASING PIN ON US BY MOVING BASE PIECE
MVDGSQ==27	;GAINING CONTROL OF SQUARE
MVDTE==30	;TOO EARLY TO MOVE THIS PIECE W/O POSITIVE REASON
MVDDVM==31	;INITIAL DEVEL MOVE
MVDPCP==32	;PIN CONSTRAINED PIECE VAL = DIF VALUE OF PIN
MVDMTP==33	;MOVING THREATNED PIECE
MVDUBP==34	;UNBLOCKING PASSED P
MVDRDF==36	;RELEASING DEFENSE
MVDINT==37	;INTERPOSING
MVDTHU==40	;DEFENDING THRU OPP'S PIECE
MVDRPI==41	;RELEASING PIN ON US BY INTERPOSING
MVDFHI==42	;FORCING HIM TO IGNORE CONSTRAINTS
			;(MVDAB MAY BE SET)
MVDPPT==43	;PINNING + THREATNIING W/PAWN
MVDAPS==44	;ATTACK STOPSQ OF OPPOSING P P
MVDCPB==45	;MOVE COVERED BY PIN, IE IF
		;HE CAPTS, THAT PIECE (HIS) WOULD BECOME BASE PIECE OF PIN
		;PINNING A CONSTRAINED PC
MVDXRY==46	;ATTACKING PC WITH LESSOR SLIDING PC.
		;IF IT MOVES, ATTACK WILL BE DISCVERED ON THIRD PC WITH POTENTIAL VALUE
MVDTRD==47	;OFFERING TRADE. JUST LIKE MVDAT BUT WAIT TO SEE IF TREAT LIKE
		;TRADE OR ATTACK
MVDPRP==50	;RELIEVING PIN OR CONSTRAINT AND THUS
		;REINFORCING CURRENTLY OUTSTANDING (BUT QUESTIONABLE) THREAT
MVDPRM==51	;THREATNING PROMOTION IE MVING P TO 7TH RANK.
		;ENTRY FOR EACH ACCESSIBLE 8TH RANK SQUARE

TR6THT:	[ASCIZ / CAPT /]	;THREAT CODES
	[ASCIZ / M ATTACK /]
	[ASCIZ / MATE THREAT /]
	[ASCIZ / STRONG ATTACK /]
	[ASCIZ / TRADE THREATNED /]
	[ASCIZ / PUSH P P/]

TR6ATT:	[ASCIZ / SEC ATT /]	;AUX THREAT CODES

DEFINE MVDM A,B,C/
IFSN A,,	A==.-TR6PT
	MVDMR [B
]
	C
TERMIN

DEFINE MVDDTA B,C
B!C!TERMIN

DEFINE MVDMR A
MVDDTA [DEFINE MVDDTA B,C
B!][A!C!TERMIN]
TERMIN

TR6PT:	MVDM ,0,[ASCIZ / CAPT /]	;MOVE DESCRIPTION CODES
	MVDM ,DFSAVE,[ASCIZ / DEF /]
	MVDM ,ALOSS,[ASCIZ / BLOCKED OUR DEF /]
	MVDM ,ALOSS,[ASCIZ / BREAK CONSTRAINT /]
	MVDM ,IGAIN,[ASCIZ / PIN /]
	MVDM ,MOVE AGAIN,[ASCIZ / ATTACK /]
	MVDM ,SQGAIN,[ASCIZ / DENYING SQ /]
	MVDM ,0,[ASCIZ / SUPPORT /]
	MVDM ,PPPGN,[ASCIZ / PUSH P P /]
	MVDM ,DFSVP,[ASCIZ / BLOCK P P /]
	MVDM ,MOVE AGAIN,[ASCIZ / BLK HIS DEF /]
	MVDM ,MOVE AGAIN,[ASCIZ / CAPT CONSTRAINED PIECE /]
	MVDM ,0,[ASCIZ / MVING INTO PRISE, CALC LOSS /]
	MVDM ,ALOSS,[ASCIZ / UNBLOCKING HIS ATTACK /]
	MVDM ,IGAIN,[ASCIZ / SETTING UP DISCOVERY /]
	MVDM ,0,[ASCIZ / RELEASING PIN ON HIM /]
	MVDM ,0,[ASCIZ / RELEASING ATT HIS PINNED PIECE /]
	MVDM ,0,[ASCIZ / HOLDING PIN /]
	MVDM ,IGAIN,[ASCIZ / ATT PINNED PIECE /]
	MVDM ,PINRLS,[ASCIZ / DEFENDING BASE PIECE /]
	MVDM ,0,[ASCIZ / PAWN BREAK /]
	MVDM ,0,[ASCIZ / RELEASING ATTACK /]
	MVDM ,PINRLS,[ASCIZ / RELEASING PIN ON US BY MOVING BASE PIECE /]
	MVDM ,SQGAIN,[ASCIZ / GAINING CONTROL OF SQUARE /]
	MVDM ,PMLSS,[ASCIZ ? TOO EARLY TO MOVE PC W/O REASON ?]
	MVDM ,0,[ASCIZ / INIT DEVL MV / ]
	MVDM ,MOVE AGAIN,[ASCIZ / PIN CONSTRAINED PC /]
	MVDM ,0,[ASCIZ / MVING THREATNED PC /]
	MVDM ,ALOSS,[ASCIZ / UNBLOCK P P /]
	MVDM ,0,[ASCIZ /  FREE /]
	MVDM ,0,[ASCIZ / RELEASING DEF /]
	MVDM ,DFSAVE,[ASCIZ / INTERPOSING /]
	MVDM ,0,[ASCIZ /DEFENDING THRU /]
	MVDM ,PINRLS,[ASCIZ /RELIEVING PIN BY INTERPOSING /]
	MVDM ,MOVE AGAIN,[ASCIZ /FORCING HIM TO IGNORE CONSTRAINT /]
	MVDM ,MOVE AGAIN,[ASCIZ /PINNING + THREATNING W P /]
	MVDM ,DFSVP,[ASCIZ /ATT STOPSQ OF P.P. /]
	MVDM ,PINRCV,[ASCIZ /COVERED BY PIN /]
	MVDM ,MOVE AGAIN,[ASCIZ /XRAY /]
	MVDM ,MOVE AGAIN,[ASCIZ /OFFER TRADE /]
	MVDM ,OSTPRP,[ASCIZ /PREP OS THREAT /]
	MVDM ,AGAIN,[ASCIZ /THREAT TO Q /]

THRUTB:	MVDDTA
		;WHAT TO DO WITH VALUES OF MVDST AT "ADD UP TIME".
	;0 IGNORE VALUE
	;4.9=1 PUSHJ TO ROUTINE
	;4.8=1 (MOVE) COMBINE INTO "AGAIN CHAIN" (IF NO MVSAB)
	;OTHERWISE ADD TO VARIABLE SPECIFIED IN RH

EXPUNGE MVDM,MVDDTA,MVDMR

;MOVE FORMAT ON PDL
;WD1 LH SQUARE RH PIECE (NORMAL HACK FOR O-O ETC)
;WD2 PLAUSIBILITY
;WD3 4.9 ALWAYS INVESTIGATE   RH EXPECTED DELTA
BMTHR==200000	; 4.8 MOVE IS A FORK (IE LMFORS >1)
BIDSF==100000	;4.7 MOVE DISCOVERS AN IMPORTANT ATTACK (LMFOR)
BPTHDS==410200	;BYTE POINTER TO BMTHR AND BIDSF
BATH==40000	;ANSWERS ALL THREATS
BASTH==20000	;ANSWERS SOME THREATS
BATHM==10000	;ANSWERS ALL BUT MINOR THREATS
PCGMCL==340200	;4.3-4.2 PCG MOVE CLASS
				;0 LGL MV (NO REAL THREAT ANSWERING OR ATTACK PWR)
				;1 HOLDING MV (NO ATT PWR BUT ANSWERS THREATS)
				;2 ATTACKING MV
BTMPM==1000	;TEMPO MOVE IE AUATHV=ALOSS=0 POS VAL >0 NTMPS >0
BNEGF==400	;HAD (ACTIVE) NEG FACTORS (IE ALOSS, ETC, .NE. 0)
BSOS==200	;HAD SOSTV .NE. 0
BQMV==100	;QUEENING MV
BMATH==40	;MOVE SEEMS TO BE A MATE (HMM)

;WD4 POSITIONALITY
;WD5
MPCLBS==360600	;4.9-4.4 MOVE CLASS (COMP WITH BEST SO FAR)
MPCLAB==300600	;4.3-3.7 MOVE CLASS (COMP WITH NEED FOR AB FLUSH)
MPCSPC==220600	;3.6-3.1 SPECIAL CLASS 0 NONE
		;RH PNTR TO WD0 MVDST SAVE BLOCK (OR 0)
;WD6 MAX POSSIBLE GAIN

NWPOS==2	;# WDS PER INERATION OF OPEN SORT
NOCM==50.	;NUMBER INTERATIONS IN OPEN SORT
NWDPM==6	;NUMBER WDS PER MOVE ON PDL

;PIN TABLE ENTRY
;WD1 LINK 4.9 PIN TO K
;WD2 4.9-4.4 ATTACKING PIECE
PINATP==360600
;4.3-3.5 PINNED SQUARE (OCC BY PIECE WHICH IS PINNED)
PINOPS==261000
;3.1-3.4 PIN DIRECTION
PINDIR==220400
;1.1-1.6 PIN BASE SQUARE
PINBS==700
;BIT 2.9 USED IN IC CHECKER
DPBIT==200000	;PIN BY DOUBLED P
BPDPB==200100	;BYTE PNTR TO ABOVE SET ON PIN BY DOUBLED PIEECES
IPBIT==100000	;PIN AT LEAST PARTIALLY DUE TO INADEQUATE PROTECTION OF BASE PIECE
BIPBIT==170100	;PNTR TO ABOVE
WSBIT==40000	;PIECE PINNED IS NOT SUPPORTED BY A P AND CANNOT BE IN ONE MOVE
BWSBIT==160100	;PNTR TO ABOVE
;WD3 PIN VALUE (APPROX LOSS IF BROKEN)

;DSCOV TABLE ENTRY (PIN BUT BASE PIECE NOT E.P. EVEN IF BROKEN)
;LIKE PINT BUT WD3 NOT PRESENT

;MV PREP TBL
MPTYP==410300	;0 RLS PIN 1 RLS CONSTRAINT
MPTHN==221100	;INDEX OF OUR THREAT (FROM ORIGON OF OUR THREAT TBL)
MPPNR==2200	;PNTR TO PIN OR CON

NWPPE==1	;# WDS IN OUR PREP ENTRY

IFN UTAPE-TS,[
TAPAC"==A
NURBUF"==3
NUWBUF"==2
UTCCHN"==2
TPCHN"=1
TPCHNA"==100
NDIR"==2
BLKSPC"==3
CLKCHN"==3
APRINT"=10005
]

IFN TS,[
TYIC==1
TYOC==2
UTYIC==3
LPTC==4
ALPTC==14
UTYOC==5
AUXTYO==6
IOT=40←27.
OPEN=41←27.
CALL=43←27.
OPER=42←27.
CLOSE=OPER 7
TYINT==1
PDLOVI==200000
CLKINT==10000
]

IFN DECTS,[
TYIC==1
TYOC==1
UTYIC==3
LPTC==4
UTYOC==5

RELEASE=71000,,
INIT=41000,,
ENTER=77000,,
OUTBUF=65000,,
OUTPUT=67000,,
LOOKUP=76000,,
INBUF=64000,,
CALLI=47000,,
JOBOPC==130
JOBFF==121
INPUT=66000,,
IN=56000,,
CALL=40000,,
]

IFN DSPLY,[
IFE TS,[DISCHN==7
FLGCHN==6
]
DISIZE==1740
]
IFE DEC,[
LPTCHN==5
LPTBSZ==300.
]
TTYCHN==4
APRCHN==3

IFE TS,DDT=34000+IFE DEC,140000

PDLL=4000.


;ASSORTED OUTPUT UUO'S
PTTY=1000,,
SOUT=2000,,
ERRTTY=3000,,
;UUOS 4-12 USED FOR PLS MOVE TRACE
ISOUT=13000,,	;LIKE SOUT BUT INTERPRET * FROBS ETC

IFE DEC,[HSTB=200000	;IF AT HACK USE MOBY TABLE IN MOBY MEMORY
	HTNE=100000-1
	HSTBV=HSTB+HTNE
	HSTBL==HSTB+2*HTNE
	HSTBVV==HSTB+3*HTNE
]

IFE DECTS,IFN DEC,HTNE=10000-1
IFN DECTS,HTNE=300-1

IFN BOOK,[BMXS==200.	;MAX NO TAGS
	BKSS==9000.	;NO BYTES IN ACTUAL BOOK]

IFN DECTS,[
BKSS=5900.
BXMS==85.
]

DEFINE RC A,B/
	RCSTO \.+1,[A]\NRMM,ZZ
	NRMM==NRMM+1
	B
	TERMIN

DEFINE RCSTO A,B,C,D
	DEFINE D!C
		A,,[.ASCII ?B?]
	TERMIN
	TERMIN

DEFINE RS A,B/
	RCSTO \.+1,[A]\NSMM,ZQ
	NSMM==NSMM+1
	B
	TERMIN

DEFINE RP A,B/
	RCSTO \.+1,[A]\NPMM,ZX
	NPMM==NPMM+1
	B
	TERMIN


NRMM==0	;NUMBER REMOTE MACROS OF FORM ZZ...
NSMM==0	;NUMBER REMOTE MACROS OF FORM ZQ...
NPMM==0	;# OF FORM ZX...

;MACRO TO DEFINE BOARD SIZE ARRAY THAT WILL NOT BE REFERENCED OFF ACTUAL BOARD
DEFINE BSIZE A
IRPS Z,,A
Z=.-2*BW-1
TERMIN
BLOCK 8*BW-2
TERMIN

DEFINE FIX A
.ZZQ==A
	MULI .ZZQ,400
	TSC .ZZQ,.ZZQ
	ASH .ZZQ+1,-243(.ZZQ)
TERMIN

DEFINE FLOAT A
.ZZQ==A
	TLC .ZZQ,232000
	FAD .ZZQ,.ZZQ
TERMIN

DEFINE MMSAVAC
	MOVEM 16,CATCSA+16
	MOVEI 16,CATCSA
	BLT 16,CATCSA+15
TERMIN

DEFINE MMRSAC
	MOVSI 16,CATCSA
	BLT 16,16
	TERMIN

;CLOCK ROUTINES HERE SO AS TO NOT GET SWAPPED OUT
IFN TS,[
INT:	0
	0
	EXCH A,INT
	MOVEM B,INTB
	MOVEM C,INTC
	TRNE A,CLKINT
	JRST CINT
CINT1:	TRNE A,PDLOVI
	JRST INT2
	TRNN A,TYINT
	JRST INT1
	SKIPE TWOGTS
	JRST @TWINTS
CINT2:	MOVEI B,TYIC
	.ITYIC B,
	JRST INT1
	CAIN B,↑W
	JRST ITYOF
	CAIN B,↑V
	JRST ITYON
	CAIE B,↑G
	JRST INTNG
	SETOM QTF
	SETZM TRLMVP
	SETZM UREADF
	SKIPGE TTYOFF
	JRST ITYON
INTNG:	CAIN B,↑S
	CLEARM UREADF
	CAIN B,↑F
	JRST DISFL
	CAIN B,↑X
	.DSTOP
INT1:	MOVE A,INT
	MOVE B,INTB
	MOVE C,INTC
	.DISMIS INT+1

DISFL:	.DCLOSE
	MOVNI B,2
	MOVEM B,FFANCY
	JRST INT1

CINT:	SKIPGE CLKCOK
	JRST CINT1
	MOVE C,CURCLK
	CAIN C,OCLOCK
	JRST CINT1
	MOVEM T,CINTTS
	SKIPL CLKSW
	JRST CINT1A
	MOVEI B,5
	ADDM B,(C)
CINT1C:	MOVEI C,WCLOCK
	JSP T,CINT1B
	MOVEI C,BCLOCK
	JSP T,CINT1B
	MOVE T,CINTTS
	JRST CINT1

CINT1A:	AOSGE CTMR1
	JRST CINT1
	MOVNI A,30.
	MOVEM A,CTMR1
	MOVE A,[64,,B]
	.GETLOC A,
	SUB B,BWCLK
	MOVEM B,WCLOCK
	MOVE A,[65,,B]
	.GETLOC A,
	SUB B,BBCLK
	MOVEM B,BCLOCK
	JRST CINT1C

CINT1B:	MOVE B,(C)
	MOVE C,2(C)	;GET BYTE PNTR
	MOVEM C,DISIP
	IDIVI B,10.
	JSR DISC
	MOVEI C,".-"0
	JSR DISC
	JSR DIS1
	JSR DIS1
	MOVE C,B
	JSR DISC
	JRST (T)

DIS1:	0
	IDIVI B,10.
	JSR DISC
	IDIVI B,6.
	JSR DISC
	MOVEI C,":-"0
	JSR DISC
	JRST @DIS1

DISC:	0
	ADDI C,"0
	DPB C,DISIP
	MOVSI C,60000
	ADD C,DISIP
	SKIPGE C
	SUB C,[440000,,1]
	MOVEM C,DISIP
	JRST @DISC

CINTTS:	0
CTMR1:	0

INTB:	0
INTC:	0
DISIP:	0

DISL2:	20156220054
	61200274040
WNUM:	607260607260
	605660343337
	20000
	61200024040
BNUM:	607260607260
	605660373737
	3000,,

]

;SUMMARY OF ARRAYS AFFECTED BY MOVE AND UNMOVE

;PIECE (PIECE NUMBER)
	;4.9=BLACK  3.6-3.8=TYPE OF PIECE 
	;1.1-2.9=ADR OF "MM" ROUTINE OR ZERO IF PIECE NON EXTANT

;NMOVES (PIECE NUMBER)
	;=NUMBER OF MOVES MADE SO FAR

;NMKING (SIDE)
	;0=>UNCASTLED 1=>CASTLED

;NUMORP (SIDE)
	;=NUMBER OF ORTHOGONALLY SLIDING PIECES

;PCATV (PIECE NUMBER)
	;1

;RPIECE (PIECE NUMBER)
	;4.9=KING

;BOARD (SQUARE NUMBER)
	;-1=>OFF BOARD
	;0=>EMPTY
	;>0=POINTER INTO PIECE ARRAY

;PIECEL (PIECE NUMBER)
	;FOR EXISTANT PIECES THEIR SQUARE NUMBER

;RFPCS (PIECE NUMBER)
	;4.9=ORTHOGONALLY SLIDING

;DDPCS (PIECE NUMBER)
	;4.9=DIAGONALLY SLIDING

;SLDPC (PIECE NUMBER)
	;4.9=SLIDING

;PVALUE (PIECE NUMBER)
	;=VALUE OF PIECE

;RPVAL (PIECE NUMBER)
	;=REAL VALUE OF PIECE

;PCBAL (SIDE)
	;TOTAL MATERIAL (K=600) EXCEPT PAWNS

;PNBAL (SIDE)
	;PAWN MATERIAL

;LMGT (PIECE NUMBER)
	;4.9=PAWN
	;1.1-2.9=ADR OF "LM" ROUTINE

;LMGSTD (PIECE NUMBER)
	;4.9=WHITE PAWN
	;1.1-2.9=ADR OF "LM" OR "LS" ROUTINE

;SNFBP (PIECE NUMBER)
	;4.9=BLACK PAWN

;PLPWN (PIECE NUMBER)
	;PLY AT WHICH PAWN WAS PROMOTED OR -1

;ASSOCIATED WITH BOARD CONTROL HACK
;NWK BOARD SIZE JFCL EXCEPT ADD C,NSKI FOR
;SQUARES IN 8 NEIGHBORHOOD OF WK.
;NBK SAME FOR NEAR BK
;PINVF VALUE INV. PROPORTIONAL TO PIECE VALUE

;RMDTB (PIECE NUMBER)
;DISPATCH FOR INCREMENTAL UPDATING ROUTINES
;SIGN SET FOR BISHOPS

;WPNC(SIDE)
	;=NUMBER OF PAWNS

;WQNC(SIDE)
	;=NUMBER OF QUEENS

;WRKC(SIDE)
	;=NUMBER OF ROOKS

;WBSC(SIDE)
	;=NUMBER OF BISHOPS

;WKNC(SIDE)
	;=NUMBER OF KNIGHTS

;WLBC(SIDE)
	;=NUMBER OF BISHOPS ON LIGHT SQS

;WDBC(SIDE)
	;=NUMBER OF BISHOPS ON DARK SQS

;SUMMARY OF ARRAYS SET BY CAT

;BDBLK (SQUARE NUMBER)
	;BLOCKING DATA

;ONEB (SQ N)
	;POTENTIAL PIN DATA ETC
	;SQUARE NUMBER OF FIRST OBSTRUCTION A SLIDING PIECE HITS FROM THAT SQUARE TO
	;SECOND OBSTRUCTION

;PPASED (PIECE NUMBER)
	;4.9=PASSED PAWN BLOCKED BY FRIENDLY PAWN
	;1.1-2.9=RANK IF PASSED PAWN,0 OTHERWISE

;PPTP (PIECE NUMBER)
	;-1=>PAWN DEFENDED BY PAWN
	;1=>FORWARD, 2=>BACKWARD, 3=>ISOLATED PAWN
	;0 OTHERWISE

;WPNFLS (FILE)
	;=NUMBER OF WHITE PAWNS

;BPNFLS (FILE)
	;=NUMBER OF BLACK PAWNS

;WNPNFL (FILE)
	;=NUMBER OF NON PASSED WHITE PAWNS

;BNPNFL (FILE)
	;=NUMBER OF NON PASSED BLACK PAWNS

;PINT (PIECE NUMBER)
	;PIN DATA

;BDA1, BDA2, AND BDA3 (SQUARE NUMBER)
	;ATTACK DIRECTION DATA

;BA (SQUARE NUMBER)
	;=BLACK ATTACKS

;WA (SQUARE NUMBER)
	;=WHITE ATTACKS


;SUMMARY OF MISCELLANEOUS ARRAYS

;NSM (PIECE NUMBER)
	;=NUMBER OF APPARENTLY SAFE MOVES AVAILABLE

;PNTB (PIECE NUMBER)
	;=BYTE POINTER TO BIT IN BPCSOP

;NPODT (PIECE NUMBER)
	;BYTE POINTER TO BIT IN NPODBT(C)

;NPOD (PIECE NUMBER)
	;=NUMBER OF ATTACKED PIECES GIVEN PIECE IS ONLY DEFENDER OF

;NPODBT (PIECE NUMBER)
	;BITS FOR NPOD

;BPREL (SQUARE NUMBER)
	;4.1-4.9=FILE NUMBER
	;3.1-3.9=RANK NUMBER
	;2.1-2.9=POSITIVE DIAGONAL NUMBER
	;1.1-1.9=NEGATIVE DIAGONAL NUMBER

;CDEVT (PIECE NUMBER)
	;CURRENT DEVELOPMENT VALUE

;NPCPT(PIECE NUMBER)
	;=ADDRESS OF W- OR B- -PNC, -KNC, -BSC, -RKC, OR -QNC
	;SIGN SET FOR QUEENS

;ASSIGNMENTS IN PIECE ARRAY

NPC==32.
NPCS==16.
BD2==12.*10.
BW==10.
PTID==270300
PID==0
KNID==1
BID==2
RID==3
QID==4
KID==5

LGAME==300.	;MAX LENGTH OF GAME IN PLIES

;BOARD ORG.
;	WHITE
;	-1 ...
;	-1 ...
;	-1 WKR1 WKN1 ... -1
;  	..


;STANDARD INTERNAL MOVE FORMAT

;4.9 =0 NO CAPT 1 = CAPT
;4.8 =0 WHITE =1 BLACK
;4.7-4.2 =NO OF MOVING PIECE  6 BITS
;4.1 3.4 =ORG SQUARE  7 BITS
;3.3 2.7 =CAP PIECE  6 BITS
;1.9 2.6 DESTIN SQ  7 BITS
;1.8 1 IF MOVE A CHECK
;1.4 1.7 GHOST ELIM  4 BITS
;	IF WHITE MOVES, SQUARE IS 2*BW+5*BW+N+1
;	IF BLACK MOVES, 2*BW+2*BW+N+1
;1.1 1.3 0 -  1 O-O 2 O-O-O 3 EP 
;4  PROMOTED TO QUEEN 5 ROOK 6 BIS 7 KNT


;HASH TABLE FORMAT

;1 WD KEY 1.1=0 WHITE TO MOVE  1 BLACK (HSTB)
;SECOND SECTION
;4.9 4.7 INFO CODE  0  ACTUAL POS VALU	(HSTBV)
;1  ACTUAL VALUE IS >= THIS VALUE(BETTER FOR SIDE TO MOVE) (NOT USED NOW)
;2  ACT VALUE IS <= THIS VALUE(WORSE FOR SIDE TO MOVE) (NOT USED NOW)
;3 POSITION REACHED IN GAME
;4 POSITION PENDING IN CURRENT SEARCH
;4.6 => 1 POS AFTER PRINC VAR IS IN GAME OR EARLIER IN SEARCH
;3.1-3.4 PLYS DEEP THIS INFO BASED ON (SUM OF BASE PLYS LEFT+PCG PLYS+FEEDOVERS LEFT) MHPLN ACT GAME
;3.6-3.5 BMTHR BIDSF
;4.4 3.7 - PUSNM1 FLD
;2.2-2.5 ACTUAL DEPTH IN TREE ENTRY GEN AT
HNPIT==120400
MHPIT==17	;MAX # IN ABOVE
;2.1 1-> THIS MV WAS A HASH FORCE (IF PMG OR PMGIN PCG) FEEDOVER TRY LOST IN PCG
;1.9 1-> MV SAVED FROM PREV SEARCH AT INCREASED DEPTH (USE ONLY FOR HASH FORCES)
;1.7 1.8 MV GEN ID
;1.1 1.6 PLAUS # OF MV AT PREV LVL
HNPLB==220400	;PLYS DEEP FIELD
MHPLN==15.	;LARGEST # IN ABOVE
HRBTS==260200	;BMTHR,BIDSF
HPUSNM==300700
HPRMN==600	;MV # OF MV THAT LED TO THIS AT PREV LVL
HPVMGI==60200	;0 PMG 1 STATEV 2 EGHACK 3 PMG IN PCG MODE
HPPMB==400	;SAVED FROM PREV SEARCH, USE ONLY FOR HASH FORCES
BHPPMB==100100	;BYTE PNTR TO ABOVE
HHFRC==1000	;THIS MOVE WAS A HASH FORCE
HHFRCB==110100	;BYTE PNTR TO ABOVE


;HSTBL
;RH LINK TO PRINC VARIATION IN HASH TBL OR -1
HSTPON==310700	;SQ OF PC TO MOVE (PRINC VAR)
HSTSQN==220700	;SQ TO MOVE TO OR 0 NONE OR 1 O-O OR 2 O-O-O
HSTPRN==400300	;SPECIAL MOVE BITS

;HSTBVV
;LH MAX LIM RH MIN LIM

;HASH TBL STORED ON DSK

;WD0,1,2,3, AS IN HASH TBL
;WD4 FULL HASH OF LINK POS

;MVDST SAVE FORMAT
;WD0 LH # WDS IN THREAT SECTION, RH # WDS IN MVDST SECTION (OR 0=END)
;WD1 MV
;THREAT SECTION
;MVDST SECTION
;SAVE NON-CANCELLED MVDST ENTRIES
NWOSMV==2	;# OVERHEAD WDS

;OPENING BOOK FORMAT

;6 BIT BYTES, 77=E  76=T  (NEXT 2 CHRS GIVE TAG NO TRANSFERRED TO)
;75 MOVE >= ADD 75 TO NEXT CHR UNLESS IT IS A 75 ETC
;REST = NO OF MOVE AS GEN BY PLAUS MOVE GEN PRIOR TO SORT
;BOOK SYM TAB  FIRST BLOCK BKSMT 6 BIT SYM
;SECOND BKSMTV RH=CHR ADR LH=DEPTH ALONG TREE

;MACRO FOR ASSEMBLING WORDS WITH VARIOUS BITS SET
DEFINE BIT A/
ZZ==0
IRPS Q,CC,[A]
IFSE [CC]+,[	ZZ=ZZ+Q
	.STOP
]
ZZ==ZZ+<SETZ>←-<Q!.>
TERMIN
ZZ
TERMIN

DEFINE CONC A,B
A!B!TERMIN

DEFINE FLT A
<.OP FADR <.OP TLC A 233000 > 0 >TERMIN

;MACRO FOR TAGGING ARRAYS OFFSET BY ONE
DEFINE PP A
IRPS Z,,A
	Z=.-1
	TERMIN
	TERMIN

;SYMBOLIC BYTE POINTERS INTO STANDARD MOVE FORMAT
MPC=340600
MPO=250700
MPTK=170600
MPTO=100700
MGHEL=30400
CHKBT==200

PTIDS=320400	;BDAST ASSOC IN PIECE
SBRLNG==40	;SEARCH WIDTH VECTOR LENGTH

IFE TS+DECTS,[.ZZ=.
LOC 41
	JSR ERROR
LOC 40+2*TTYCHN
	JSR TTYBRK
LOC 40+2*APRCHN
	JSR IAPRBRK
LOC .ZZ]

IFN TS,[.ZZ==.
LOC 41
	JSR ERROR
	JSR INT
LOC .ZZ]

IFN DECTS,[
.ZZ=.
LOC 41
	JSR ERROR
LOC 124
	JRST RENTER
LOC 140
	JRST GO
LOC DECASA
]

JRST GO

LMGD:	0	;REAL PLY DEPTH OF CURRENT ANALYSIS
LMGD2:	0	;PSEUDO DEPTH

PP PIECE:,
OPIECE:	REPEAT 2,[
ZZ=1
	REPEAT 8,0 PID,MMWPWN	;WHITE
IFE .RPCNT,WKR:
	<<ZZ>←3+RID>←23.+MMRK
ZZ=ZZ+1
	0 KNID,RMWN
	<<ZZ>←3+BID>←23.+MMBS
ZZ=ZZ+1
IFE .RPCNT,WKING:
	0 KID,RMWK
	<<ZZ>←3+QID>←23.+MMQN
ZZ=ZZ+1
	<<ZZ>←3+BID>←23.+MMBS
ZZ=ZZ+1
	0 KNID,RMWN
IFE .RPCNT,WQR:
	<<ZZ>←3+RID>←23.+MMRK
ZZ=ZZ+1

IFE .RPCNT, BPIECE:  BPV=.-PIECE

	REPEAT 8,SETZ PID,MMBPWN	;BLACK
IFE .RPCNT,BKR:
	SETZ+<<ZZ>←3+RID>←23.+MMRK
ZZ=ZZ+1
	SETZ KNID,RMBN
	SETZ+<<ZZ>←3+BID>←23.+MMBS
ZZ=ZZ+1
IFE .RPCNT,BKING:
	SETZ KID,RMBK
	SETZ+<<ZZ>←3+QID>←23.+MMQN
ZZ=ZZ+1
	SETZ+<<ZZ>←3+BID>←23.+MMBS
ZZ=ZZ+1
	SETZ KNID,RMBN
IFE .RPCNT,BQR:
	SETZ+<<ZZ>←3+RID>←23.+MMRK
ZZ=ZZ+1
]

PP NMOVES:,	BLOCK NPC	;NUMBER OF MOVES FOR EACH PIECE

NMKING:	0	;0=UNCASTLED 1=CASTLED FOR WHITE
	0	;FOR BLACK

NUMORP:	3	;NUMBER OF ORTHOGONALLY SLIDING PIECES FOR WHITE
	3	;FOR BLACK

BDAST:	0	;MAPS COMPACTED CODE USED IN BDBLK TO PIECE NUMBER
	REPEAT 2,[
	IRP A,,[WKR,WKR+2,WKING+1,WKING+2,WQR]
	A+NPCS*.RPCNT-PIECE
TERMIN
]
	LOC BDAST+20


PP PCATV:,	REPEAT 32.,	1

PP NSM:,	BLOCK NPC	;NUMBER OF APPARENTLY SAFE MOVES PER PIECE


PP RPIECE:,	REPEAT 2,[
	REPEAT 11.,0	;SIGN NEG FOR KINGS
	SETZ
	REPEAT 4,0
]

PP CDEVT:,	BLOCK NPC

TXTB:	ASCII /WP!/
	ASCII /WN!/
	ASCII /WB!/
	ASCII /WR!/
	ASCII /WQ!/
	ASCII /WK!/

	ASCII /BP!/
	ASCII /BN!/
	ASCII /BB!/
	ASCII /BR!/
	ASCII /BQ!/
	ASCII /BK!/

TXTB1:	ASCII /P!/+"P
	ASCII /N!/+"N
	ASCII /B!/+"B
	ASCII /R!/+"R
	ASCII /Q!/+"Q
	ASCII /K!/+"K


PP TXTB2:,	REPEAT 2,[
	ASCII /KRP!/
	ASCII /KNP!/
	ASCII /KBP!/
	ASCII /KP!/
	ASCII /QP!/
	ASCII /QBP!/
	ASCII /QNP!/
	ASCII /QRP!/
	ASCII /KR!/
	ASCII /KN!/
	ASCII /KB!/
	ASCII /K!/
	ASCII /Q!/
	ASCII /QB!/
	ASCII /QN!/
	ASCII /QR!/
]

PP PLPWN:,	REPEAT NPC,-1	;PLY AT WHICH PAWN WAS PROMOTED

PP RMDTB:,	REPEAT 8,RMWP	;REMOVE PIECES ROUTINES SIGN SET FOR B'S
	RMWR
	RMWN
	SETZ RMWB
	RMWK
	RMWQ	;RMWQ +RMBQ REALLY SAME
	SETZ RMWB
	RMWN
	RMWR
	REPEAT 8, RMBP
	RMBR
	RMBN
	SETZ RMBB
	RMBK
	RMBQ
	SETZ RMBB
	RMBN
	RMBR

GHLOC:	0	;LOCN OF GHOST OR ZERO IF NONE
GHSD:	0	;   - = BLACK + WHITE

DIRDT:	0
RDT:	-1
	1
	BW
	-BW

BDT:	BW-1
	BW+1
	-BW+1
	-BW-1

TXDIR:	ASCII /LR!/	;NAMES OF DIRECTION AS PER ENTIRES IN BDA'S
	ASCII /RR!/
	ASCII /DF!/
	ASCII /UF!/
	ASCII /LLD!/
	ASCII /LRD!/
	ASCII /URD!/
	ASCII /ULD!/
	ASCII /NLR2!/
	ASCII /NLL2!/
	ASCII /NUR2!/
	ASCII /NRL2!/
	ASCII /NLR!/
	ASCII /NLL!/
	ASCII /NUR!/
	ASCII /NUL!/
	ASCII /EPL!/
	ASCII /EPR!/

INVDT:	1	;NUMBER OF OPPOSITE DIRECTION
	0
	3
	2
	6
	7
	4
	5


BOARD:	REPEAT 2*BW,-1	;THE INTERNAL BOARD
	REPEAT 8,[-1
	REPEAT 8,0
	-1
]
	REPEAT 2*BW,-1

PP PIECEL:,	;FOR EACH EXISTANT PIECE, A POINTER INTO BOARD
	BLOCK NPC


PP NPCPT:,	;ADDRESS TO SOS IF PIECE GOES AWAY
	REPEAT 8,WPNC
	WRKC
	WKNC
	WBSC
	NWKG	;!
	SETZ WQNC
	WBSC
	WKNC
	WRKC
	REPEAT 8,BPNC
	BRKC
	BKNC
	BBSC
	NBKG	;!
	SETZ BQNC
	BBSC
	BKNC
	BRKC

PP NPCP1:,	;ANOTHER ADDRESS TO SOS IF PC GOES AWAY
	REPEAT 10.,NPCTEM	;DOES SOMETHING ONLY FOR B'S
	WLBC
	REPEAT 2,NPCTEM
	WDBC
	REPEAT 12.,NPCTEM
	BDBC
	REPEAT 2,NPCTEM
	BLBC
	REPEAT 2,NPCTEM

NPCTEM:	0	;RANDOM

;BELOW ARRAYS MUST BE IN GROUP
PP SPINT:,	BLOCK NPC	;CONSTRAINT TABLE
PP IATT:,	BLOCK NPC	;I ATTACK
PP ATTME:,	BLOCK NPC	;ATTACK ME
PP IDEF:,	BLOCK NPC	;I DEF
PP DEFME:,	BLOCK NPC	;DEF ME

SPINFS:	0	;FREE STG CNR FOR SPINDT
SPINFM:	0	;SPINFS LVL BETWEEN CONSIDERING PARTICUAR MOVE

LSPINLT==600
SPINDT=.-1
	BLOCK LSPINLT	;STG FOR SPINT, THRU DEFME


MSSW:	1	;MULTIPLE SEARCH SWITCH
ICSW:	-2	;INCREMENTAL CAT SWITCH 0 NO IC -1 CHK OR 1 IC -2 SPOT CHECK
LNSW:	0	;.NE. 0 ENABLE LINE ANALYSIS
PPVSW:	0	;+ PRINT STATIC EVAL - ALSO DEVEL VALUES AFTER MOVE TYPED IN
INVCLK:	0	;XORED WITH CLOCK KLUDGE
PARSW:	0	;1 MACHINE SELECTS PARAMETERS
ALGSW:	0	;0 DESCRIPTIVE 1 ALGBRADIC -1 BOTH
PMDDSW:	0	;1 SHOW THREATS SECONDARY PINS PINS EN PRISE
MVANSW:	1	;1 USE NEW CALC GAIN FINDER ETC
SSSW:	1	;1 USE SEARCH STRATEGY HACK
DFDSW:	0	;1 USED DELAYED FEEDOVER HACK
PCGSW:	2	; USE P.C.G. FOR N PLYS AFTER BASIC DEPTH (PLUS FEEDOVERS)
EST:	0	;ESTIMATE FOR MULT SEARCH
ESTSW:	0	;-1 EST SET BY COMMAND DONT RECOMPUTE IF SAME PLYN
SETESP:	0	;PLYN FOR ABOVE

EGSW:	0	;1 USE END GAME HACK
DBDSSW:	1	;1 DEBUGGING OUT TO DIS, 0 TO TTY
FCSW:	1	;1 USE FORWARD CUTOFF HACK
SASW:	0	;DO SUPRISE AND THIS MANY PLIES DOWN
PMSASW:	1	;DO POOR MAN'S SURPRISE ANAL THIS MANY PLIES DEEP
CORSIZ:	ICORSZ	;CURRENT COR SIZE
HRCSW:	1	;UPDATE HSH TBL FEATURE
PARCSW:	1	;DO PAR CHECK CYCLES
TWOGTS:	0	;1 THINK WHILE OTHER GUY THINKING
SQCTSW:	1	;1 USE SQUARE CTL IN STATEV
MVNSW:	1	;1 USE PC MOBILITY
CASSW:	0	;1 O-O,O-O-O ARE "PLAUSIBLE CAPTURES"

;4.9-4.7 0 SOUT 1 TYPE AS SIXBIT 2 PUSHJ 3 DPT 4 DPT RIGHT ADJ TO 24 MULT
; 5 FLOATING PT 4.6 SAYS NO CR 4.5 SAYS TAB TO 24 MULT 6 FIXED FRACTION
INFDT:	100000,,VNAME1
	100000,,VNAME2
IFN TS,[	200000,,DATP
	200000,,TIMP
]
	40000,,[ASCIZ /SETD=/]
	300000,,HK1V
	40000,,[ASCIZ /SETW=/]
	200000,,PSETW
	40000,,[ASCIZ /SETP=/]
	200000,,PSETP
	40000,,[ASCIZ /SETF=/]
	300000,,FDCUT
	40000,,[ASCIZ /SETFD=/]
	300000,,FDDCUT
	40000,,[ASCIZ /PCGSW=/]
	300000,,PCGSW
	40000,,[ASCIZ /EST=/]
	300000,,MSIBB
	40000,,[ASCIZ /SETEST=/]
	300000,,ESTSW
	40000,,[ASCIZ /ALPHA/]
	300000,,BPREV
	40000,,[ASCIZ /BETA/]
	300000,,BPREV+1
	40000,,[ASCIZ /ACTIVITY DELTA/]
	600000,,ACTV
	40000,,[ASCIZ /BCS=/]
	300000,,NSBVS
	40000,,[ASCIZ /HASH=/]
	300000,,NHSW
	40000,,[ASCIZ /KINGSA=/]
	300000,,KINGSW
	40000,,[ASCIZ /SFS=/]
	300000,,FIS
	40000,,[ASCIZ /DFDSW=/]
	300000,,DFDSW
	40000,,[ASCIZ /EMTLSW=/]
	300000,,EMTLSW
	40000,,[ASCIZ /WTPWSW=/]
	300000,,WTPWSW
	40000,,[ASCIZ /WTPCSW=/]
	300000,,WTPCSW
	40000,,[ASCIZ /PWBSW=/]
	300000,,PWBSW
	40000,,[ASCIZ /ACTVSW=/]
	300000,,ACTVSW
	40000,,[ASCIZ /SSSW=/]
	300000,,SSSW
	40000,,[ASCIZ /LNSW=/]
	300000,,LNSW
	40000,,[ASCIZ /ICSW=/]
	300000,,ICSW
	40000,,[ASCIZ /EGSW=/]
	300000,,EGSW
	40000,,[ASCIZ /FCSW=/]
	300000,,FCSW
	40000,,[ASCIZ /SASW=/]
	300000,,SASW
	40000,,[ASCIZ /HRCSW=/]
	300000,,HRCSW
	40000,,[ASCIZ /PARCSW=/]
	300000,,PARCSW
	40000,,[ASCIZ /TWOGTS=/]
	300000,,TWOGTS
	40000,,[ASCIZ /CSQSW=/]
	300000,,CSQSW
	40000,,[ASCIZ /SQCTSW=/]
	300000,,SQCTSW
	40000,,[ASCIZ /MVNSW=/]
	300000,,MVNSW
	40000,,[ASCIZ /BOOK=/]
	300000,,UBKF
	40000,,[ASCIZ /PMSASW=/]
	300000,,PMSASW
	40000,,[ASCIZ /CASSW=/]
	300000,,CASSW

LINFDT==.-INFDT

VNAME1:	.FNAM1
VNAME2:	.FNAM2

STAPT:	60000,,[ASCIZ /P.M.G. RUN/]
	400000,,NPL
	60000,,[ASCIZ /STATEV RUN/]
	400000,,NSV
	60000,,[ASCIZ /PMG IN PCG MODE/]
	400000,,PCGMC
	60000,,[ASCIZ /FEEDOVERS/]
	400000,,NFD
	60000,,[ASCIZ /FEEDOV LIM REACHED/]
	400000,,NMFD
	60000,,[ASCIZ /MOVES MADE/]
	400000,,NMMV
	60000,,[ASCIZ /HASH MATCH P.M./]
	400000,,NHMCH
	60000,,[ASCIZ /HASH MATCH STATEV/]
	400000,,NHMSB
	60000,,[ASCIZ /TOTAL HASH MATCH/]
	400000,,THTM
	60000,,[ASCIZ /SECONDARY LINE ANAL/]
	400000,,NSLA
	60000,,[ASCIZ /MULT SEARCHES/]
	400000,,NSRCHS
	60000,,[ASCIZ /SFS CUTOFFS/]
	400000,,NSFSC
	60000,,[ASCIZ /# INV AT PMG/]
	400000,,NMINV
	60000,,[ASCIZ /# REJ PRIOR TO BEST/]
	400000,,NMRJ
	60000,,[ASCIZ /DLY DFOV ATT/]
	400000,,NDFDA
	60000,,[ASCIZ /# LOSERS/]
	400000,,NDFDL
	60000,,[ASCIZ /NATEVC=/]
	400000,,NATEVC
	60000,,[ASCIZ /ATEVLC=/]
	400000,,ATEVLC
	60000,,[ASCIZ /ATEVEC=/]
	400000,,ATEVEC
	60000,,[ASCIZ /NEVRCP/]
	400000,,NEVRCP
	60000,,[ASCIZ /# FORW CUT/]
	400000,,NFCO
	60000,,[ASCIZ /# POS W FCO/]
	400000,,NPWFCO
	60000,,[ASCIZ /# HSH FORCES/]
	400000,,NHFRC
	60000,,[ASCIZ /# PAR CHECK CYCLS/]
	400000,,NPCCY
	60000,,[ASCIZ /AVG # OF BEST MV/]
	500000,,RJRTO

LSTAPT==.-STAPT

SWSTF:	40000,,[ASCIZ /PARS DFR EMTLSW=/]
	300000,,EMTLSW
	40000,,[ASCIZ /WTPWSW=/]
	300000,,WTPWSW
	40000,,[ASCIZ /WTPCSW=/]
	300000,,WTPCSW
	40000,,[ASCIZ /PWBSW=/]
	300000,,PWBSW
	40000,,[ASCIZ /ACTVSW=/]
	300000,,ACTVSW

LSWSTF==.-SWSTF

LHFLT==20
HFLT:	BLOCK LHFLT	;RECORD LEVELS OF HASH MATCHES
LSHFLT==20
SHFLT:	BLOCK LSHFLT	;MUST IMMEDIATELY FOLLOW HFLT

IFN TS,[
EHRNM:	0	;RUN TIME AT WHICH ENTERED HACK1
EHRTM:	0	;REAL TIME AT WHICH ENTERED HACK1
]
MSIB:	200	;OFFSET FOR INITIAL ALPHA AND BETA
MSIBB:	0	;INITIAL GUESS EVALUATION
LSSFL:	0	;-1 IF CURRENT SEARCH MUST GIVE FINAL RESULTS
NPLNCP:	0	;NUMBER PLY SINCE P MOVE OR CAPTURE
CURCKS:	0	;CLOCK AT ENTRY
PPNTF1:	0
PPNTF2:	0
DBSUPS:	0	;-1 DONT UPDATE DATA BASE AT MMOVE, ETC

NPL:	0	;NO TIMES PLAUS MV GEN RUN
NSV:	0	;NO TIMES STATEV RUN
NFD:	0	;NO FEEDOVERS
NABF:	0	;NO ALPHA BETA FLUSHES
NMFD:	0	;NO TIMES REACHED MAX FEEDOVER LIMIT
NSVS:	0	;NO TIMES STATEV CALLED SELF
NCAT:	0	;NO TIMES CAT RUN
NMMV:	0	;NO TIMES MMOVE RUN
NHMCH:	0	;NO HASH MATCHES PLS MOVE
NHMSB:	0	;NO HASH MATCHES STAT BOARD EV
NFDCK:	0	;NO OF FEEDOVERS IN CH AND NO KING MOVES
NSLA:	0	;NO SECONDARY LINE ANAL
THTM:	0	;NET TOTAL HASH MATCHES
.TIME:	0	;THINKING TIME
..TIME:	0	;THINK PER MAIN VARIATION
OPNMID:	0
NSFSC:	0	;NUMBER SFS CUTOFFS
NMRJ:	0	;NUMBER MOVES REJECTED
NMINV:	0	;NUMBER MOVES INVESTIGATED AT PMG
NDFDA:	0	;NUMBER DELAYED FEEDOVERS
NDFDL:	0	;NUMBER THAT LOST
PCGMC:	0	;PMG IN PCG MODE
NATEVC:	0	;NUMBER TIMES ATEVE USED BECAUSE MORE THAN 5 BEAR ON A SQ
ATEVLC:	0	;NUMBER TIMES ATEVL CALLED
ATEVEC:	0	;NUMBER TIMES ATEVE CALLED
NEVRCP:	0	;NUMBER TIMES SQUARE RECOMPUTED DUE TO HACKAGE IN PMG
NFCO:	0	;# FORW CUTTOFFS
NPWFCO:	0	;# POS W/ AT LEAST ONE FCO
NHFRC:	0	;# HASH FORCES
OPENF:	0	;LAST LOCN CLEARED AT HACK1

PCRAT1:	0	;CHANGE IN RATIO HACK (SEE STVL4)
PNRAT1:	0	;ABOVE FOR PAWNS
PCRAT2:	0	;PCBAL DIFF AT TOP
PNRAT2:	0	;PNBAL DIFF AT TOP
CCANF1:	0	;TEMP AT CCAN
LPPMN:	0	;PLAUSIBILITY RANK OF MOVE THAT GOT TO THIS POSITION
SAFSP:	0	;FREE P TO SAVE AREA F S
SABEG:	0	;BEG OF SAVE AREA
SATEM:	0	;PNTR TO FIRST WD SAVE AREA OF CURRENT MOVE

IFN TS,..TSTM:	0	;RUN TIME AT LAST P.V.

NSRCHS:	0	;NUMBER SEARCHES REQUIRED
RJRTO:	0	;AVG NUMBER MOVES INVESTIGATED BEFORE BEST FOUND AT PMG
DISSUP:	0	;-1 DONT UPDATE DISPLAY AT MNLP2
GESTSW:	0	;-1 EST FROM GAME 0 OTHERWISE
NPCCY:	0	;# PARAMETER CHECK CYCLES

;TREE RELATIVE SWITCHES
;MAY HAVE VALUES OF 1,0,-1,-2 (STORED IN 2 BITS IN GAMEV)
EMTLSW:	0	;-1 IF MATERIAL SUBSTANTUALLY EVEN AT TOP
		;IE SAVE TIME BY ELEMINATING PIECE RATIO HACK
WTPWSW:	0	;1 W WANTS TO TRADE PAWNS 0 DOESNT CARE -1 DOESNT WANT TO
WTPCSW:	0	;1 W WANTS TO TRADE PCS 0 DOESNT CARE -1 DOESNT WANT TO
PWBSW:	0	;0 NO  P BREADTH HACK 1 FOR W -1 FOR BLACK
ACTVSW:	0	;0 NOT ACTIVITY HACK 1 LACK OF ACTIVITY BENEFITS WHITE
			;-1 BLACK
NRLSWS==.-EMTLSW

SRLSWS:	BLOCK NRLSWS	;SAVED STATE OF SWITCHES

SRLCPF:	JFCL	;COMPARE FUNCTIONS XCT THIS IF SWITCH DFRS TO DEFERMINE IF IMPORTANT OF NOT
	SKIPA	;SKIP IF RECOMPUTE
	SKIPA
	SKIPA
	PUSHJ P,ACTC1


ACTC1:	IMUL R,ACTVSW
	SKIPE ACTV
	CAMG R,[-2*PWNV]
	POPJ P,
	JRST POPJ1


LGMST1:	0
	NPCS
	0

LGMST2:	-NPCS,,0+1
	-NPCS,,NPCS+1
	-NPCS,,0+1

TRPPCF:	0	;-1 IF B MAY BE TRAPPED BY P-N3

;PRELIM THREAT ANALYSIS
HTHRP:	0	;POINTER TO BEG OF BLACK AGAINST WHITE THREAT TABLE
	0	;PNTR TO WHITE AGAINST BLACK THREATS
NHTHR:	0	;NUMBER BLACK AGAINST WHITE THREATS
	0	;# WHITE AGAINST BLACK
TTLHT:	0	;SUM VALUE BLACK AGAINST WHITE THREATS
	0	;VAL WHITE AGAINST BLACK
LTHR:	0	;LARGEST OUTSTANDING THREAD B VS W
	0	;W VS B
NQTHR:	0	;# QUESTIONABLE THREATS B AGAINST W
	0	;# W AGAINST B
OLTHR:	LTHR+1
	LTHR

MPBAS:	0	;PNTR TO MOVE PREP TBL
NMP:	0	;# ENTRIES IN MV PREP TBL

SIDTM:	0	;SIDE TO MOVE
PLSUPV:	0	;IF THIS VALUE EXCEEDED FOR SIDE TO MOVE, WILL
			;CAUSE SURPRISE AT HIGHER LEVEL (OR SETZ => NONE)
PLMVDP:	0	;PNTR TO THREAD-MVDST SAVE TBL FOR MOVE WE PLAYED PREV LEVEL
		;OR 0=> NONE
MVDSP:	0	;POINTER TO MOVE DESCRIPTION TABLE
MVDMF:	0	;POINTER TO MVDST AFTER CONSTANT FACTORS FOR ALL MOVES OF PIECE
		;COMPUTED AT LMGCD
MVDDP:	0	;POINTER TO MVDST AFTER FACTORS GENERATED BY DISCOVERIES
NPPIN:	0	;# POSSIBLE PINS STORED IN MVDST
PCSATS:	0	;SUPER STATIC VALUE OF BOARD AS IT STANDS
AHDATS:	0	;NET LACKING FOR AB CUT (-POSBGF)
ABFATS:	0	;NET LACKING FOR BSF (-POSBGF)
POSBGF:	30	;AMT TO ALLOW EXTRA IN ABOVE CALCS TO ALLOW FOR
		;POSSIBLE POSITIONAL CHNGS ETC.
PMVORG:	0	;PNTR TO BEG OF MOVE TABLE ON PDL
HPMVP:	0	;PNTR TO PMV FOR HIS PCS ON PDL.
			;(USE TO PASS CPCMVL TO LOWER LVL IF THEY GET CAPTED)
THRT1:	0	;TEMP
THRT2:	0	;-1 IF FIRST THREAT TO CAPTURE PIECE
THR3CT:	0	;TMP
THRSAF:	-1	;0 AT LEAST 1 SEC THREAT STORED FOR THIS THREAT
ATHRPP:	0	;TEM FOR LAST D AT CLOS1
ATHRPS:	0	;ATHRP AT BEG OF THREAT
THQST:	0	;-1 IF FACT HIS PC WAS PINNED WAS IGNORED IN FIGURING THREAT OR E.P.
PMDDT1:	0	;PDL AT PMDD1
PMDDT2:	0	;TEMP AT PMDDN
GDNMAG:	0	;AMT ATS IS BETTER THAN NEEDED IF GDNATS = -1
GDNATS:	0	;-1 PCS ATS GOOD ENUF IF HIS THREATS ANSWERED
INCHK:	0	;0 NOT IN CHECK (IN CURRENT POSITION) 
		;1 IN CHECK -1 DOUBLE CHECK
QMOVE:	0	;CURRENT MOVE AT PMG INVOLVES QUEENING (IF -1)
TPNTM1:	0	;VALUE OF THREAT AGAINST BASE PC AT TPN1
CANTK:	0	;IN PCG MODE, -1=> SIDE TO MOVE CAN TAKE PCSATS
CANMV:	0	;IN PCG MODE -1=> NOT IN CHECK OR HAVE LGL MV
HEXP:	0	;HIGHEST "EXPECTATION" FOR ANY MV
NNBLDR:	0	;# NON "BLUNDERS" AVAIL (IE EXPECTATION>-100)
STPALL:	0	;-1 => MV REALLY ANSWERS (NOT JUST CONTERS OR DEFERS) ALL HIS THREATS
NTMPMV:	0	;# TEMPO MVS
BSTPMV:	0	;BEST POSITION MOVE (WITH EGAIN >0)
BSTPV:	0	;POSITIONALITY OF ABOVE
SBPMV:	0	;SECOND BEST POSITIONAL MOVE
SBPV:	0	;POSITIONALITY OF ABOVE
PCGMD:	0	;-1 PMG IN PCG MODE
PCGCF:	0	;PCG CUTTOF IF -1
PCGT1:	0	;TEM
SRTI:	0	;-1 IF 4SORT RUN THIS LVL
SASWL:	0	;-1 STORE THREAT-MVDST SAVE STUFF THIS LVL
EVHCL:	0	;CLASS OF HIGHEST CLASS MV THAT EXISTS
NTPCC:	0	;.NE. 0 => HAVE PCS WITH NO SAFE MVS
LGCLSW:	0	;STG FOR CLASS WD PRIOR TO PUSHAGE
TTLTVI:	0	;INITIAL VALUE OF THTVAT
THTVAT:	0	;AMT OF CURRENT SUBTHREAT UNANSWERED
THSMUA:	0	;LARGEST AMT ANY SUBTHREAT UNANSWERED
THLST:	0	;LARGEST SUBTHREAT
THVTAS:	0	;THTVAT AFTER ANSWERING ANAL GOING INTO COUNTERING ANAL
THANCT:	0	;TEM
CCAL:	0	;RE CAPT THREAT LEFT (DURING SUBTHREAT ANAL)
TMVTRC:	0	;LARGEST AMT COUNTERED IN ANY SUBTHREAT
TMLTPO:	0	;TEMPO OF CURRENT SUBTHREAT
VALTPO:	0	;TEMPO OF LARGEST UNANSWERED SUBTHREAT SO FAR
LMPLF:	0	;# PLYS OF BASIC DEPTH LIMIT LEFT
RPVD:	6	;DEPTH IN PCG INVESTIGATE "PROMISING" MOVES
PMGTRF:	0	;IF -1 WANT TO TRACE PMC IN AFTER MODE
POSHSA:	0	;HASH ADR
LMGGPS:	0	;GAME LVL AT LMGH1
THJS:	0	;SAVE J AROUND THREAT ANAL
PVPCCP:	0	;POS VAL OF PC CAPTED (FOR USE IN F.C. CALC)
NSCTHR:	0	;# SINGLE CAPT THREATS
NMCTHR:	0	;# MULT CAPT THREATS
PCMVNG:	0	;PIECE MOVING
ORGPCL:	0	;ORG LOCN OF MVING PC
PCMPLL:	0	;PDL LEVEL AT LMGRA
CKDIR:	0	;DIRECTION OF CHECK (IF SLIDING)
CKPC:	0	;PC CHECKING
HFCTMP:	0	;TMP
ESPHM:	0	;PNTR TO RET THR-MVDST ENTRY HIS MOVE (OR 0)
ESAVL:	0	;SURPRISE ANAL VAL (AT ESA)
ESPCHT:	0	;PC HE TOOK (IN SURPRISE ANAL)

PP PUATV:,	BLOCK NPC	;AMT OF UNANSWERED THREAT ASSIGNED TO THREATS BY THIS PC
			;(SINGLE CAPT THREATS ONLY)

NSACSQ:	-1	;# SQUARES TO SAC PC (DEF ONLY BY K) -1
SACSQ:	BLOCK 8	;SQUARE
SACPC:	BLOCK 8	;PC
SACAMT:	BLOCK 8	;AMT OF SAC
SACVL:	BLOCK 8	;EXCESS VALUES OF MVS ATTACKING SAC SQ
SACLK:	BLOCK 8	;LINKS TO OTHER SACS ALSO THREATNED (DURING ANAL OF SINGLE MV)
SACQA:	BLOCK 8	;-1 IF Q CAN CHECK AFTER SAC

SACFL:	-1	;LINK TO SACLK OF SACS THREATNED BY MV OR -1

WTSI:	WTPWI(I)	;WANT TO TRADE SW 0 PW
	WTPCI(I)	;1 PC

WTPWI:	SKIPG WTPWSW	;SKIP ON WANT TO TRADE PAWNS
	SKIPL WTPWSW

WTPCI:	SKIPG WTPCSW	;SKIP ON WANT TO TRADE PCS
	SKIPL WTPCSW

DCTSI:	SKIPE WTPWSW	;SKIP ON DONT CARE IF TRADE PAWNS
	SKIPE WTPCSW	;PCS

OTRPP:	HTHRP+1	;PNTR TO OUR THREATS AGAINST HIM
	HTHRP

OTVPP:	TTLHT+1	;PNTR TO TOTAL VALUE OUR PRELIM THREATS AGAINST HIM
	TTLHT

OTNPP:	NHTHR+1	;PNTR TO # OUR THREATS AGAINST HIM
	NHTHR


DEFINE DGDTA B,C
B!C!TERMIN

DEFINE DGMR A
DGDTA [DEFINE DGDTA B,C
B!][A!C!TERMIN]
TERMIN

DEFINE DGCLS A,B,C/
A	0
	DGMR [[ASCIZ ? B ?]
]
TERMIN
;# OF MOVES IN SEARCH PRIORITY CLASSES

;CHARACTERISTIC OF MOVE IF REALIZED GOOD ENUF FOR A,B CUTTOFF
;IN DESCENDING ORDER OF SEARCH PRIORITY.  PARTICULAR MOVE ENTERED ONLY
;IN HIGHEST CLASS IT QUALIFIES FOR.

DGCLSB:
DGCLS DGNG:,[DG>,UATV,ALOSS=0]	;DIRECT GAIN GOOD ENUF, UATV,ALOSS=0
DGCLS DGNGU:,[DG-UATV-ALOSS>]	;DIRECT GAIN-UATV-ALOSS
DGCLS DGST:,[DG+STHR-UATV-ALOSS>]	;DIRECT GAIN +STRONG THREATS - UATHV -ALOSS
DGCLS DGSTA:,[DG+STHR-ALOSS-UATV(IMMED ONLY)>]	;DIRECT GAIN+ STRONG THREAT  DOES NOT ANSWER
		;ALL THREATS, BUT TEMPO VALUE OF ATTACK IS GREATER THAN
		;VALUE OF THREAT.
DGCLS DGOT:,[DG+STHR+THREAT-UATHV-ALOSS>]	;DIRECT GAIN +SA + ORDINARY THREATS -UATHV-ALOSS
DGCLS DGOTA:,[DG+STHR+THREAT-ALOSS-UATHV(IMMED ONLY)>]	;SAME BUT DONT SUBTRACT VALUE OF UNANSWERED
		;THREATS WHOSE TEMPO VALUE IS LESS THAN OUR SA+ ORDINARY THREATS
DGCLS DTHR:,[+ALL POS VALUES-NONE>]	;"THREATENS" TO BE GOOD ENUF (ALL POSITIVE VALUES
		;NO NEGATIVE ONES
DGCLS DPOSV:,[HAS POSITIVE VIRTUE]	;"HAS POSITIVE VIRTUE"
DGCLS DIRVM:,[INDIFFERENT]	;APPARENT IRRELAVENT MOVES
DGCLS DDBDM:,[HAS - VIRTUE]	;DISTINCTLY BAD MOVE
DGPRCL==.-DGNG	;NUMBER PRIMARY CLASSES

;SPECIAL CLASSES HAVING  RELAVANCE ONLY IN CERTAIN GLOBAL SITUATIONS
DGCLS DDESP:,[DESPERADO]	;"DESPERATO MOVE"
		;IF 1) HAVE MV OF  LARGE + GAIN (POST) 2) HE HAS OUTSTANDING THREAT
		;AGAINST PC P (PRE)3) MV AVAIL TO ANSWER THREAT (POSSIBLY AT LOSS)
		;WITH TEMPO > HIS THREAT WITH E.P. PIECE
		;4) HIS E.P. PIECE CANNOT RECAPT  5) NUMBERS ADD UP
DGCLS DATM:,[MV MAY ATTACK K]	;MOVE MIGHT CONTAIN THREAT TO HIS K
DGCLE1:
DGCLS2:	;CORRESP WITH ABOVE BUT COMPARE TO NEED FOR BEST SO FAR
	BLOCK DGCLE1-DGCLSB
DGCLE:
DGTXT:	DGDTA
EXPUNGE DGDTA,DGCLS,DGMR

DEFINE GAINM A
IRPS B,,[A]
B:	0
	GAINRM [[ASCIZ /B/]
]
TERMIN
TERMIN

DEFINE GAINRM A
GAIND [DEFINE GAIND B,C
B!][A!C!TERMIN]
TERMIN

DEFINE GAIND B,C
B!C!TERMIN


;VALUES ASSOCIATED WITH VARIOUS PHASES OF MOVE
BGNS:
HPVAL:
GAINM CGAIN:,		;VALUE OF MATERIAL CAPTURED
GAINM EGAIN:,		;NET ESTIMATED ON CAPTURE + EP OF DIR MOVE
GAINM OSTCMP:,		;OUTSTANDING THREAT COMP (UP TO MAX OF CCA)
				;IE IF HE TAKES US, WE TAKE OUTSTANDING THREAD (OFFSETS -EGAIN)
GAINM AGAIN:,		;"SUM" VALUE OF THREATS UPPER BOUND
GAINM PGAIN:,		;"POTENTIAL GAIN" (LESSOR THREATS)
GAINM IGAIN:,		;INDIRECT THREATS (THREATNED DISCOVERIES ETC)
GAINM SAGAIN:,		;VALUE OF STRONG THREATS (IE PIECE PINNED, MULT ATTACK ETC)
;VALUES IN DAGAIN AND SDAGN CANCEL THAT MUCH -EGAIN (IN MOST CASES)
GAINM DAGAIN:,		;VALUE OF THREAT ASSOCIATED WITH DISCOVERED ATTACKS OR FORCING HIM TO IGNORE CONSTRAINT
GAINM SDAGN:,		;STRONG THREAT WITH DISCOVERED ATTACK OR FORCING HIM TO IGNORE CONSTRAINT
			;POSSIBLE GAIN BY CAPTURING HIS PIECES THAT WERE CONSTRAINED
			;OR BLOCKING HIS DEFS 
GAINM PPPGN:,		;GAIN DUE TO PUSHING PASSED P'S
GAINM DFSAVE:,		;VALUE OF POSSIBLE LOSS AVOIDED (DEFS, ETC)
					;ACCOUNTED FOR IN THREAT HACKAGE
GAINM DFSVP:,		;LOSS AVOIDED NOT ACCOUNTED FOR IN THREAT HACKAGE (ATT STOPSQ OF P.P.)
			;(OR BLOCK P P)
GAINM RICKF:,		;-1 REAL CHECK FLAG
GAINM MATTH:,		;-1 "MATE" OR NEAR MATE THREATNED
GAINM ALOSS:,		;POSSIBLE LOSS DUE TO LEAVING THINGS LOOSE, BLOCKING DEFS, ETC
GAINM UATHV:,		;VALUE OF LARGEST UNANSWERED THREAT
GAINM SLUATV:,		;VALUE OF SECOND LARGEST UNANSWERED THREAT
GAINM AUATHV:,		;VALUE OF ALL UNANSWERED THREATS COMBINED
GAINM UALTPO:,		;TEMPO OF UATHV
GAINM VTHRA:,		;SUM VALUE OF THREATS ANSWERED
GAINM CMTHRA:,		;SUM "COMPONENT" THREATS ANSWERED
GAINM PMLSS:,		;"LOSS" DUE TO PREMATURE MOVING OF PC W/O REASON
GAINM TGAIN:,		;GAIN THREATNED, BUT HE CAN TRADE IF NOT OCCUPIED
GAINM TPPOC:,		;TRADE PIECE PINNED OR CONSTRAINED FLAG
GAINM BCONGN:,		;VALUE OF CONSTRAINTS HE HAS TO BREAK
GAINM RCTMPO:,		;AMT HE LOSES FROM EGAIN IF HE FAILS TO RECAPTURE
GAINM OFTRCL:,		;AMT WE LOOSE BY "FAILING TO CAPTURE LAST"
GAINM VTHRAC:,		;VALUE OF THREATS "COUNTERED" BY COUNTER ATTACKS
			;WITH VAL+TMPO OF HIS THREAT < RCTMPO
GAINM ALOSSC:,		;VALUE OF CONSTRAINTS "COUNTERED"
GAINM 20LAGN:,		;SUM (20 LOG TERMS OF AGAIN)
GAINM LAGN:,		;LARGEST TERM IN AGAIN
GAINM SLAGN:,		;SECOND LARGEST TERM IN AGAIN
GAINM NTMPS:,		;# TIMES MV INVOLVES ATTACT HIM WITH LESS
GAINM LRCCOD:,		;LOCAL RECAPTURE CODE -2 IMPOSS -1 UNLIKELY
			;0 POSSIBLE (TRADE) 1 EXPECTED 2 CERTAIN
GAINM RCCOD:,		;GLOBAL RECAPTURE CODE (VALS SAME AS ABOVE)
GAINM HCL:,		;-1 TO GET EGAIN, HE TAKES LAST
GAINM NHC:,		;# TIMES HE CAPTS TO GET EGAIN
GAINM CCA:,		;CAPT COUNTER AVAIL
GAINM PINRCV:,		;"RECAPT VAL" OF PIN HE GETS INTO IF HE CAPTS US
GAINM PINRLS:,		;VALUES DUE TO RELEVING PINS ON US
GAINM OSTV:,		;SUM OF VALUE OF CURRENT THREAT AGAINST HIM THAT WILL STILL BE THREATNED
GAINM LOSTV:,		;LARGEST OF ABOVE
GAINM SOSTV:,		;STRONG
GAINM LSOSTV:,		;LARGEST STRONG 
GAINM OSTPRP:,		;VALUE OF CURRENT QUESTIONABLE OUTSTANDING THREATS NOW DEFINITELY THREATNED (DUE TO RELIEVING PINS, ETC)
GAINM RCTHR:,		;TO HOLD LOSS TO INDICATED ON UNANSWERED THREATS, WE MUST
			;RECAPTURE OR LOOSE THIS ADDTL AMT
GAINM SQGAIN:,		;VALS ASSOC WITH CONTROLLING SQS
GAINM NDA:,		;# DISCOVERED ATTS ON HIS PCS
GAINM NIUBLK:,		;# IMPORTANT DISCOVERIES ON OUR PCS
GAINM CEGAIN:,		;AMT (-) EGAIN COUNTERED
GAINM QGAIN:,	;GAIN FOR THREATNING TO QUEEN
;THESE VAR MUST BE TOGETHER
;USED TO DECIDE WHETHER TO TREAT OFFERED TRADES AS
;TRADES OR ATTACKS
GAINM PATVL:,		;PRELIM VAL OF ATTACKS (DIRECT)
GAINM DPATVL:,		;"  (DISCOV)
GAINM TRDS:,		;# TIMES TRADE OFFERED DIRECT
GAINM DTRDS:,		;" " (DISCOV)
EGNS:
GAINM EPGNE:,		;MOVING PIECE OUT OF PRISE
GAINM RUMVLU:,	;MAKING ROOM FOR E.P. PC
GAINM FREVLU:,	;MAKING ROOM FOR PC W/ NO SAFE MVS (COUNT # SQS)
EGNNMS:	;END OF GAIN NAMES 

GANNTB:	GAIND
EXPUNGE GAIND,GAINRM,GAINNM

PP LNCP:,	BLOCK NPC	;PIECE CAPTURED IN PRINCIPAL VARIATION

BPREV:	0	;BEST KNOWN WHITE
	0	;BEST KNOWN BLACK

IBPRV:	0	;INITIALIZED VALUES OF BPREV AT HACK1
	0	;IF NOT = TO EVMST  OK FOR BEST SO FAR TO BE POSSIBLY BETTER

LMG5T1:	0

PCSWSM:	0	;NO PIECES W/ SAFE MOVES
NSMVS:	0	;NO SAFE MOVES FOR CURRENT PIECE
NCKF:	0	;NO SAFE CHECKS
ICKF:	0	;CURRENT MOVE A SAFE CHECK

;IN REPLAY MODE
RWPF:	0	;-1 PLAY WHITE MOVES 0 READ WHITE MOVES
RBPF:	0	;SAME FOR BLACK
RPLYPN:	0	;PLY #

TACNTP:	0	;PNTR TO ATTACK CONSTRAINTS TBL
TACTB:	BLOCK 40	;CONSTRAINTS DEVEL AS A RESULT OF ATTACKS
		;WD1 PC,,SQ
		;WD2 AMT

;MEDIUM RANGE GOAL TABLE
;FREE PIECE
;DISLODGE HIS PIECE
;DEFEND SQUARE
;PREPARE BREAK
;ATTACK WEAKNESS
;EXCHANGE PIECES
;AVOID EXCHANGES
;OCCUPY WEAK SQUARE WITH (P)
;RELIEVE PIN
;MAKE LUFT
;ATTACK STOPSQAURE OF P P
;OCCUPY STOPSQUARE OF P P
;CENTRALISE K
;RELEASE K (IF PENNED IN BY R ETC
;REMOVE CONSTRAINT ON OUR PIECE
;OCCUPY OPEN FILE
;DOUBLE, TRIPLE ETC ON FILE
;EXECUTE ROOK LIFT
;EXECTUTE K ATTACK
;REDEPLOY PIECES TO AREA
;ATTEMPT TO TRAP PIECE
;CHASE OFF (BLOCK) ATTACK ON SQUARE (TO PERMIT O-O ETC)


;GAME STATUS DESC
;QUICK SAFE WIN FOR WHITE
;LONG WINNING ENDGAME FOR WHITE
;PROBABLE WINNING ADVANTAGE FOR WHITE
;SUBSTANTUAL ADVANTAGE FOR WHITE
;SLIGHT ADVANTAGE FOR WHITE
;EVEN
;ETC FOR BLACK

;GAME CHARACTER DESC
;CLOSED - HALF OPEN - OPEN

;GAME TEMPO DESC
;WHITE HAS INITIATIVE
;WHITE HAS ADVANTAGE + CAN EXPLOIT STRAIGHT-FORWARDLY
;WHITE CAN MAKE MAJOR IMPROVEMENTS BY WAY OF REDEPLOYMENT, DEVELOPMENT
;WHITE CAN MAKE MINOR IMPROVEMENTS
;WHITE REDUCED TO WAITING STRATEGY

;ETC FOR BLACK

;GAME STRATEGY
;WHITE PLAYING FOR WIN
;WHITE PLAYING FOR DRAW
;WHITE DESPERATE
;BLACK PLAYING FOR WIN
;BLACK PLAYING FOR DRAW
;BLACK DESPERATE

;WINNING/LOSING/CERTAINITY HACK
;PRED WINNING          PRED LOSING
; WC > EVENT WIN, THEN MIN (LC + INV C)   LC > SURE LOSS, MAX WC+ INV C

;CONTRIBUTIONS TO UNCERTAINTY
;FEEDOVER IN THIS LINE
;REL OF REJECTED LINES TRIED THIS LVL
;PCS AT THEY STAND AT THIS LVL-P.V. VALUES

;PASS THREATS TO LOWER LEVELS
;AGGRESSIVE-DEFENSIVE VARIABLE

RDAT:	BDARL(A)
	BDARR(A)
	BDAFB(A)
	BDAFT(A)
BDAT:	BDALL(A)
	BDALR(A)
	BDAUR(A)
	BDAUL(A)

	BDALR2(A)
	BDALL2(A)
	BDAUR2(A)
	BDAUL2(A)
	BDALR1(A)
	BDALL1(A)
	BDAUR1(A)
	BDAUL1(A)
	BDAEPL(A)
	BDAEPR(A)

RDATS:	BDARL(C)
	BDARR(C)
	BDAFB(C)
	BDAFT(C)
	BDALL(C)
	BDALR(C)
	BDAUR(C)
	BDAUL(C)

RDATSS:	BDARL(S)
	BDARR(S)
	BDAFB(S)
	BDAFT(S)
	BDALL(S)
	BDALR(S)
	BDAUR(S)
	BDAUL(S)

	BDALR2(S)
	BDALL2(S)
	BDAUR2(S)
	BDAUL2(S)
	BDALR1(S)
	BDALL1(S)
	BDAUR1(S)
	BDAUL1(S)
	BDAEPL(S)
	BDAEPR(S)

RDATSQ:	BDARL(Q)
	BDARR(Q)
	BDAFB(Q)
	BDAFT(Q)
	BDALL(Q)
	BDALR(Q)
	BDAUR(Q)
	BDAUL(Q)

RDAT1:	BDARL(T1)
	BDARR(T1)
	BDAFB(T1)
	BDAFT(T1)
	BDALL(T1)
	BDALR(T1)
	BDAUR(T1)
	BDAUL(T1)

RDATI:	BDARR(A)	;RDAT FOR OPPOSITE DIRECTION
	BDARL(A)
	BDAFT(A)
	BDAFB(A)
	BDAUR(A)
	BDAUL(A)
	BDALL(A)
	BDALR(A)


RMPPT1:	CAIE B,6
	CAIE B,3

RMPPT2:	SKIPLE T1,BOARD+BW(A)
	SKIPLE T1,BOARD-BW(A)

RMPPT3:	SKIPL SNFBP-PIECE(T1)
	SKIPL LMGSTD-PIECE(T1)

RMPPT4:	CAIN B,5
	CAIN B,4

RMPPT5:	SKIPE T1,BOARD+2*BW(A)
	SKIPE T1,BOARD-2*BW(A)

RMPPT7:	BOARD+BW+1(A)
	BOARD-BW+1(A)

RMPPT8:	BOARD+BW-1(A)
	BOARD-BW-1(A)

RMPTA:	BOARD-BW+1(A)
	BOARD+BW+1(A)

RMPTB:	BOARD-BW-1(A)
	BOARD+BW-1(A)

RMINS:	ADDM R,WA(A)
	ADDM R,BA(A)


RMDTT:	CAILE C,5	;SKIP ON DIAG TOWARD BLACK
	CAIG C,5	;SKIP ON DIAG TOWARD WHITE
	CAILE C,5

RMDTT1:	CAILE D,5
	CAIG D,5


RMP5T:	REPEAT 4,RFPCS(S)
	REPEAT 4,DDPCS(S)

RMP5T1:	REPEAT 4,RFPCS-PIECE(D)
	REPEAT 4,DDPCS-PIECE(D)


	;DATA BASE ARRAYS SET UP BY CAT
	;
BDBLK:	BLOCK BD2	;BLOCKING DATA
ONEB1:	BLOCK BD2	;SQUARES HIT BY SLIDING PIECE THRU ONE OBSTRUCTION
ONEB2:	BLOCK BD2
WPAS:	BLOCK BD2	;VALUE OF ATTACK ON SQUARE FOR PDV
BPAS:	BLOCK BD2
;PNTRS TO WPAS AND BPAS
NPPAS==300	;NUMBER P POTENTIALLY ATTACKING SQ
NPPASB==1	;1.1-1.3
NPAS1==30300	;NUMBER P ATTACKING IN ONE MOVE
NPAS1B==10	;1.4-1.6
NPAS==60300	;NUMBER P ACTUALLY ATTACKING SQ
NPASB==100	;1.7-1.9
NNAS==110300	;NUMBER N S
NNASB==1000	;2.1-2.3
NBAS==140300	;NUMBER B S
NBASB==10000	;2.4-2.6
NRAS==170300	;NUMBER R S
NRASB==100000
NQAS==220300	;NUMBER Q S
NQASB==1,,
NKAS==250300	;N K S
NKASB==10,,

OPOM:	NPAS1,,WPAS(T1)	;# OUR P IN ONE MV
	NPAS1,,BPAS(T1)

PP ATLSP:,	REPEAT 8,0	;BYTE PNTR TO FIELDS IN HIS AS FOR GUYS LESS THAN ME
	61100,,BPAS(A)	;R
	60300,,BPAS(A)	;N
	60600,,BPAS(A)	;B
	61700,,BPAS(A)	;K
	61400,,BPAS(A)	;Q
	60600,,BPAS(A)	;B
	60300,,BPAS(A)	;N
	61100,,BPAS(A)	;R
	REPEAT 8,0
	61100,,WPAS(A)
	60300,,WPAS(A)
	60600,,WPAS(A)
	61700,,WPAS(A)
	61400,,WPAS(A)
	60600,,WPAS(A)
	60300,,WPAS(A)
	61100,,WPAS(A)

PASI:	ADDM J,WPAS(A)
	ADDM J,BPAS(A)
	ADDM J,WPAS(A)

PASIS:	ADDM J,WPAS(S)
	ADDM J,BPAS(S)
	ADDM J,WPAS(S)


PP PASIN:,	REPEAT 2,[
	REPEAT 8,NPPASB
	NRASB
	NNASB
	NBASB
	NKASB
	NQASB
	NBASB
	NNASB
	NRASB
]
PP PMV:,	BLOCK NPC	;PIECE MOBILITY VALUE ACCUMULATED FOR SQUARES
				;TO WHICH PIECE COULD MOVE WITHOUT BEING E.P.
				;COMPUTED AT STVL4
PP PGLST:,	BLOCK NPC	;PNTR TO OTHER P'S IN PAWN GROUP

PP PDV:,	BLOCK NPC	;CURRENT PIECE DEVELOPMENT VAL
		;VALUES FOR HITTING SQUARES REGARDLESS
		;OF SQUARE CONTROL ASSIGNED
		;FROM WAV, BAV (MAINTAINED INCREMENTALLY)

WAV:	BLOCK BD2	;VALUE FOR WHITE ATTACK ON EACH SQUARE
BAV:	BLOCK BD2	;VALUE FOR BLACK ATTACK ON EACH SQUARE

;ALL RANKS IN WDPRK,BDPRK EXPRESSED FROM WHITE'S POINT OF VIEW
WDPRK:	REPEAT 10.,10.	;RANK OF LEAST ADV W P IN FILE (10. IF NONE)
BDPRK:	REPEAT 10.,0	;RANK OF LEAST ADV B P IN FILE (0 IF NONE)

AT:	ADD W,WAV(A)
	ADD W,BAV(A)

ATS:	SUB W,WAV(A)	;MUST IMMEDIATELY FOLLOW AT
	SUB W,BAV(A)

	;
	;PAWN STRUCTURE ARRAYS
PP PPASED:,	;RANK IF PASSED PAWN, 0 OTHERWISE
		;4.9=1 IF PASSED AND BLOCKED BY FRIENDLY PAWN
	BLOCK NPC
PP PPTP:,	;-1=PAWN DEFENDED BY PAWN
		;1=FORWARD, 2=BACKWARD, 3=ISOLATED PAWN
		;0 OTHERWISE
	BLOCK NPC	;CAT DEPENDS ON LAST REGISTER OF PPTP TO =0
;START OF AREA CLEARED BY COMMON BLT IN CAT

WPNFLS:	BLOCK 10.	;NUMBER OF WHITE PAWNS IN FILES
BPNFLS:	BLOCK 10.	;BLACK (MUST HAVE 0 FOR FILES 0 & 9)
WNPNFL:	BLOCK 10.	;NUMBER OF NON-PASSED WHITE PAWNS IN FILES
BNPNFL:	BLOCK 10.	;BLACK (MUST HAVE 0 FOR FILES 0 & 9)

WPPRK:	BLOCK 10.	;RANK OF MOST ADV W P.P. ON FILE
BPPRK:	BLOCK 10.	;"   "  BLACK  "

WAAPP:	BLOCK 10.	;WHITE ATTACKS ON SQS IN FRONT OF MOST ADV BLACK P P ON FILE
BAAPP:	BLOCK 10.	;BLACK ... WHITE P.P.

NWPPP:	0	;# WHITE PASSED P
NBPPP:	0	;# BLACK PASSED P

PP PNSTS:,	BLOCK NPC	;4.9=0 UNFREE =1 HALF-FREE OR PASSED
		;4.8,4.7 0 RANGER 1 HOME 2 CENTER
		;4.6-4.4 0 NIL 1 CANDIDATE 2 HELPER 3 HELPER TO THE N
		;4.3 FAKER
		;4.2-4.1 0 NIL 1 RAM 2 LEVER 3 DUO

PP FILST:,	BLOCK 8	;0 CLOSED -1 HALF OPEN 1 OPEN

WPGRPS:	0	;PNTR TO WHITE PAWN GRPS
BPGRPS:	0	;PNTR TO BLACK P.G.

PP ODSCV:,	BLOCK NPC	;LIKE PINT BUT "PINNED PIECE" IS OURS
;(IE THREATENING DISCOVERY ON HIM).

PP BPINT:,	BLOCK NPC	;0 OR PNTR TO PINDT (CONTENTS IDENTICAL TO CORRESP ENTRY
			;FOR PIECE PINNED) IN WHICH GIVEN PIECE IS BASE PIECE
PP DSCOV:,	BLOCK NPC	;LIKE PINT BUT BASE PIECE THEORITICALLY NOT E.P. EVEN IF "PIN" BROKEN
PP PINT:,	;PIN DATA
	BLOCK NPC	;0 PIECE NOT PINNED ELSE PNTR TO PINDT
	;
; END OF AREA CLEARED IN COMMON BLT
BDA1:	BLOCK BD2	;ATTACK DIRECTION DATA
BDA2:	BLOCK BD2
BDA3:	BLOCK BD2
	;
BA:	BLOCK BD2	;BLACK ATTACKS ON EACH SQUARE
	;
WA:	BLOCK BD2	;WHITE ATTACKS ON EACH SQUARE

WIMP=WAV	;TEMP (?)
BIMP=BAV
;BSIZE WIMP:,	;ESTIMATED IMPORTANCE OF SQUARE TO WHITE
;BSIZE BIMP:,	;ESTIMATED IMPORTANCE OF SQUARE TO BLACK
BSIZE WPCOR:,	;4.9 MORE THAN 6 WHITE PIECES BEAR ON SQUARE
	;4.8-4.3 LEAST VALUABLE W PC. SEVEN BIT BYTES FROM THERE
	;100 BIT PC UNCOVERED REST PC NUMBER
BSIZE BPCOR:,	;SIMILAR FOR BLACK

BSIZE CNTRL:,	;STATUS OF SQUARE AND PNTRS TO PIECES
		;THAT HAVE BEEN AWARDED PNTS FOR THIS SQUARE
BSQSP==330400	;4.4-4.1 STATUS
		;4.8 PUSHABLE INTOABLE WHITE
		;4.7 PUSHABLE INTOABLE BLACK
OBSQP==220400	;OLD SQ CTL PREV TO DISCOVERY (DURING LMG)
WCTLF==60600	;2.3-1.7 WHITE PC CREDITED
BCTLF==600	;1.6-1.1 BLACK PC CREDITED
MCFMSK==777760,,-1	;MASK TO AVOID CLEARING OBSQP

MSQWUC==0	;WHITE UNCONTESTED
MSQWSC==1	;WHITE STRONGLY CONTROLLED
MSQWC==2	;WHITE CONTROLLED
MSQWD==3	;WHITE DEFENDED
MSQE==4	;EVEN
MSQUC==5	;UNCONTESTED
MSQBD==6	;BLACK DEFENDED
MSQBC==7	;BLACK CONTROLLED
MSQBSC==10	;BLACK STRONGLY CONTROLLED
MSQBUC==11	;BLACK UNCONTESTED

;STRONGLY CONTROLLED MEANS AT LEAST A 2 TO 1
;NUMERICAL ADVANTAGE WITH OUR LEAST < HIS
;CONTROLLED MEANS LEAST VAL PCS EVEN
;AND NUMERICAL ADV FOR US
;DEFENDED MEANS FEWER NUMBER BUT OUR SMALLEST < HIS

BPCHD:	BLOCK BD2	;0 IF SQUARE NEEDS RECALULATION -1 OTHERWISE

LPGSP==20	;LENGTH PAWN GROUP SAPCE
PP PGSP:,	REPEAT LPGSP,.+1	;RH PNTR TO NEXT P.G. OR 0
	0	;2.1-2.5 PNTR TO PAWN LIST
		;2.6-3.3 PNTR TO OPPOSING GROUP 0 PASSED
	;4.8-4.7 0 EVEN 1 MAJ 2 MINORITY
	;4.9 WEAK (ONE OR MORE PAWNS IN GRP WEAK)
	;4.6 1 CRIPPLED MAJORITY
	;4.5-4.4 0 NIL 1 ONE OR MORE CANDIDATE 2 1 OR MORE PASSED
;MAX RANK
;MIN CONNECTED RANK

PGSFS:	PGSP+1	;FS PNTR FOR PGS

CTLTXT:	ASCIZ /WUC /
	ASCIZ /WSC /
	ASCIZ / WC /
	ASCIZ / WD /
	ASCIZ / E  /
	ASCIZ / U  /
	ASCIZ / BD /
	ASCIZ / BC /
	ASCIZ /BSC /
	ASCIZ /BUC /

CTLFAC:	10	;4.9 =0 USE WAV =1 USE BAV
	6
	4
	3
	0
	0
	-3
	-4
	-6
	-10

	[0]	;MUST BE AT PPT, MAY BE REFERENCED AT MMBPWN
PP PPT:,	REPEAT 2,[REPEAT 8,PIECEL+.-PPT
	REPEAT 8, [0]
]

BDBSQ:	400400,,BDBLK(A)
	340400,,BDBLK(A)
	300400,,BDBLK(A)
	240400,,BDBLK(A)

BDBD:	200400,,BDBLK(A)
	140400,,BDBLK(A)
	100400,,BDBLK(A)
	40400,,BDBLK(A)

ONEBSQ:	331100,,ONEB1(A)
	221100,,ONEB1(A)
	111100,,ONEB1(A)
	1100,,ONEB1(A)

ONEBBD:	331100,,ONEB2(A)
	221100,,ONEB2(A)
	111100,,ONEB2(A)
	1100,,ONEB2(A)

ONEBS:	331100,,ONEB1(S)
	221100,,ONEB1(S)
	111100,,ONEB1(S)
	1100,,ONEB1(S)
	331100,,ONEB2(S)
	221100,,ONEB2(S)
	111100,,ONEB2(S)
	1100,,ONEB2(S)

REVERS:	REPEAT 10.,9-.RPCNT	;RANKS FROM BLACKS SIDE

OURGY:	SKIPGE (D)
	SKIPL (D)
	SKIPGE (D)

HKNG:	CAIN D,BKING
	CAIN D,WKING

BPINTK:	WKING-PIECE+BPINT	;PNTR TO BPINT FOR OUR K (THINGS PINNED TO K)
	BKING-PIECE+BPINT

OURGY1:	SKIPL (T1)
	SKIPGE (T1)
	SKIPL (T1)

OURGY2:	SKIPGE (T2)
	SKIPL (T2)
	SKIPGE (T2)

OURGY3:	SKIPGE (B)
	SKIPL (B)
	SKIPGE (B)

OURGY4:	SKIPGE (Q)
	SKIPL (Q)
	SKIPGE (Q)

RMOY:	SKIPGE PIECE(B)
	SKIPL PIECE(B)
	SKIPGE PIECE(B)

RMOY1:
RMOY3:	SKIPGE PIECE(S)
	SKIPL PIECE(S)
	SKIPGE PIECE(S)

RMOY2:	SKIPGE PIECE(Q)
	SKIPL PIECE(Q)
	SKIPGE PIECE(Q)

RMOY4:	SKIPGE PIECE(T1)
	SKIPL PIECE(T1)
	SKIPGE PIECE(T1)

RMOY5:	SKIPGE PIECE(D)
	SKIPL PIECE(D)

RMOY6:	SKIPGE PIECE(T2)
	SKIPL PIECE(T2)
	SKIPGE PIECE(T2)

RMOYTT:	SKIPGE PIECE(TT)
	SKIPL PIECE(TT)
	SKIPGE PIECE(TT)

LPINDT==30.	;MAX NUMBER OF ACTIVE PINS
PINFS:	PINDT	;PIN TABLE FREE STG PNTR
PINDT:	BLOCK LPINDT*2*3	;THREE WDS/PIN ENTRY, TWO ENTRIES/PIN 
			;(PIECE PINNED AND BASE PIECE)

EPINDT:


;WHITE NEAR SIDE
;HIGHER NOS TOWARD BLACK
BDARL=360600,,BDA1	;RANK FROM LEFT
BDARR=300600,,BDA1	;"  "  RIGHT
BDAFB=	220600,,BDA1	;FILE  "  BOT
BDAFT=140600,,BDA1	; "  "  TOP
BDALL=60600,,BDA1	;DIAG  "  LOWER LEFT
BDALR=600,,BDA1	;DIAG "  "  RIGHT
BDAUR=360600,,BDA2	;DIAG  "  UPPER  "
BDAUL=300600,,BDA2	;"  "  "  LEFT
BDALR2=220600,,BDA2	;KNIGHT  2*BW  FROM  LR
BDALL2=140600,,BDA2	;KNIGHT  "   "    LL
BDAUR2=60600,,BDA2	;"  "   "  UR
BDAUL2=600,,BDA2	;"  "  "  UL
BDALR1=360600,,BDA3	;"  BW  "  LR
BDALL1=300600,,BDA3	;"  "  "  LL
BDAUR1=220600,,BDA3	;"   "    "   "  UR
BDAUL1=140600,,BDA3	;"  "  "  UL
BDAEPL=60600,,BDA3	;EP FROM L
BDAEPR=600,,BDA3	;EP FROM R

MCATT2:	REPEAT 4,	SKIPL RFPCS(D)
	REPEAT 4,	SKIPL DDPCS(D)

MCATT3:	-1	;PIECE AND SIDE BEING PINNED AGREE
	1	;DISAGREE


CATFLG:	-1

MMPWNF:	0	;PASSED PAWN BLOCKED BY FRIENDLY PAWN FLAG

PP PTPTB:,
PP RFPCS:,	;NEGATIVE FOR ORTHAGONALLY SLIDING PIECES
	REPEAT 8,PTPWP
	SETZ RMWR
	RMWN
	RMWB
	RMWK
	SETZ RMWQ
	RMWB
	RMWN
	SETZ RMWR
	REPEAT 8,PTPBP
	SETZ RMBR
	RMBN
	RMBB
	RMBK
	SETZ RMBQ
	RMBB
	RMBN
	SETZ RMBR

PP DDPCS:,	;NEGATIVE FOR DIAGONALLY SLIDING PIECES
	REPEAT 2,[
	BLOCK 12
	-1
	0
	-1
	-1
	BLOCK 2
]
PP SLDPC:,	;NEG FOR SLIDING PIECES
	REPEAT 2,[
	BLOCK 8
	-1
	0
	-1
	0
	-1
	-1
	0
	-1
]


LPINTB=100
PINTB:	BLOCK LPINTB
RMERR1:	0	;PDL SAVED AT GSYL
LCHAR:	0	;LAST CHAR READ (AT GSYL4)
ALGSW1:	0	;SWITCH TO HOLD SQ WHILE RETN PIECE
CALGNF:	0	;COMMITTED TO ALGEBRADIC

IFN HSCOD,NHSW:	1	;-1=SUPPRESS ALL HASH 0=ALLOW DRAW DET ONLY
IFN BOOK,UBKF:	0	;0=DON'T USE BOOK  1=USE BOOK
IVVDD:	2	;EFFECTIVE SETD FOR SEC INV
INVD:	0	;SEC INVEST START FROM THIS PLY OR LESS

HACKMX:	0	; MAX POSITON VALUE FROM LAST SEARCH
HACKMN:	0	;MIN VALUE
HACKSD:	0	;SIDE LAST MV MADE FOR
POSMAX:	0	;KNOW POS VAL NO HIGHER THAN THIS
POSMIN:	0	;NO LOWER
CATSCC:	0	;I C CAT SPOT CHECK COUNT
CSQSW:	1	;1 CALC WPCOR BPCOR FOR ALL SQS AT STVL4

PP EVMPB:,	REPEAT NPC, <43-.RPCNT>←12.+100,,ESPHI(P)
SBR:	;SEARCH BREADTH VECTOR
	REPEAT SBRLNG,6

PSBR:	6	;MAX # POSITIONAL ONLY MVS TO LOOK AT (LVL)
	6
	3
	3
	REPEAT SBRLNG-.+PSBR,2

IFN KILLH,[
AKHS:	1
IRPC X,,ABC
ABFT!X:	BLOCK SBRLNG+1
TERMIN
]


PP LGLMPT:,	;PIECE IN B CUR LOC IN S DESTIN IN A
	REPEAT 8,LWPWN
	LROOK
	LKNT
	LBIS
	LKING
	LQUEEN
	LBIS
	LKNT
	LROOK
	REPEAT 8,LBPWN
	LROOK
	LKNT
	LBIS
	LKING
	LQUEEN
	LBIS
	LKNT
	LROOK

STPLVL:	0	;DISPLAY STOP LEVEL
DBS1:	0	;0 NO DISP 1 DISPLAY 2 DISPLAY FEEDOVERS 3 TYPE LIST OF PLAUS MOVES
DBS2:	0	;0 NO LOOK AHEAD 1 LOOK AHEAD AFTER DISPLAY MUST FOLLOW DBS1
SDBS1:	0	;SAVED AT TRACE
SDBS2:	0	;SAVED AT TRACE MUST FOLLOW
MVDS:	0	;MAIN VARIATION DIS SWITCH

DSPACE:	MOVEI A,40
	JRST (B)

DTAB:	MOVEI A,11
	JRST (B)

DCOLON:	MOVEI A,":
	JRST (B)

DSLASH:	MOVEI A,"/
	JRST (B)

DPERD:	MOVEI A,".
	JRST (B)

FORMF:	MOVEI A,14
	JRST (B)

LATYO:	MOVEI A,"←
	JRST TYO

QMTYO:	MOVEI A,"?
	JRST TYO

OKINGT:	WKING-PIECE+PIECEL
	BKING-PIECE+PIECEL
	WKING-PIECE+PIECEL

LMUATS:	0
LMUDR:	0
ATTHF:	0	;-1 IF S ROUTINE MOVES THRU OPPONENTS PIECE OF HIGHER VAL (OR=)

LMUAT1:	BRANK,,BPREL(S)
	BRANK,,BPREL(S)
	BFILE,,BPREL(S)
	BFILE,,BPREL(S)
	BPDAG,,BPREL(S)
	BMDAG,,BPREL(S)
	BPDAG,,BPREL(S)
	BMDAG,,BPREL(S)

LMUAT:	BRANK,,BPREL(A)
	BRANK,,BPREL(A)
	BFILE,,BPREL(A)
	BFILE,,BPREL(A)
	BPDAG,,BPREL(A)
	BMDAG,,BPREL(A)
	BPDAG,,BPREL(A)
	BMDAG,,BPREL(A)


BDLNR:	BRANK,,BPREL(R)
	BRANK,,BPREL(R)
	BFILE,,BPREL(R)
	BFILE,,BPREL(R)
	BPDAG,,BPREL(R)
	BMDAG,,BPREL(R)
	BPDAG,,BPREL(R)
	BMDAG,,BPREL(R)


BDLNC:	BRANK,,BPREL(C)
	BRANK,,BPREL(C)
	BFILE,,BPREL(C)
	BFILE,,BPREL(C)
	BPDAG,,BPREL(C)
	BMDAG,,BPREL(C)
	BPDAG,,BPREL(C)
	BMDAG,,BPREL(C)


;ATTRIBUTE VALUES

OPATV:	10	;UNCOVERING ATTACK ON ADEQUATELY DEFENDED PIECE
IVLU:	2000.	;INITIAL
MJVLU:	100	;MORE ATTACKS THAN OPP
TTVLU:	20	;ATTACK POORLY DEFENDED PIECE
BSQVAL:	10	;BASIC SQUARE VALUE
NKVLU:	20	;NEAR KING VALUE
CSQV:	20	;CENTER SQUARE VALUE EARLY
NCSQV:	10	;NEAR CENTER VALUE EARLY
WPVLU:	-400	;TOO EARLY TO MOVE PIECE UNLESS ATTACKED
BRKVLU:	50	;PAWN BREAK
FMKING:	40	;FIRST KING MOVE
KKCAS:	200	;FIRST KING MOVE IF CASTLE IS POSSIBLE
FMROOK:	60	;FIRST ROOK MOVE IF CASTLE IS POSSIBLE
MPFMV:	44	;FIRST MOVE OF MINOR PIECE

PTFVLU:	20	;MOVING TO SAME RANK OR FILE AS OPP KING +
POFVLU:	60	;MOVEING TO OPEN FILE SAME AS KING +
BCPVLU:	140	;BLOCKING PAWN BY PLAYING TO K3 OR Q3 -
BDDMT:	-60	;THRES FOR MOVE TO BE BAD DEVL WISE
GMAVLU:	140	;CHANGE BALANCE OF POWER ON OTHER THAN PAWN DEF. BY PAWN +
ACSPV:	50	;PLAUSIBLITITY VAL ATTACKING CENTER SQUARE W PAWN +
APVLU:	100	;ATTACKING A PINED PIECE +
APDPV:	20	;ATTACKING A PINNED PAWN WHICH IS DEFENDED BY PAWN +
APFVLU:	14	;ATTACKING PAWN ON FILE +
AWPVLU:	50	;ATTACKING WEAK P (FOR B ISO) +
APFPV:	20	;EXTRA IF PASSED AND NOT BLOCKED BY FRIENDLY P +

LMMPDP:	0	;MOVING P DEFENDED BY P -
LMMFP:	4	;MOVING FORWARD P + (MAYBE TRY TO TRADE)
LMMBP:	30	;MOVING BACKWARD P +
LMMIP:	4	;MOVING ISOLATED P +
RDEFVLU:	10	;VALUE FOR RANDOMLY DEFENDING OUR PIECE

PINVLT:	60	;VALUE FOR PIN OF PIECE AS FUNCTION OF RANK (ATTACK NOT SIG)
	50
	50
	60
	70
	100
	110
	110

PINVAT:	140	;ALSO REPRESENTS ATTACK
	120
	120
	140
	160
	200
	220
	220

;PLAUS VALUES ADDED TO MOVE
LMFPT:	100	;ATTACKING TWO
	240	;3
	400	;4
	600	;5 OR MORE

;PASSED PAWN PUSH VALUES(PLAUS)

PPP:	10	;NOTE RANK PSEUDO REDUCED BY 2 FOR PP BLOCKED BY FRIENDLY
	10
	40	;BLOCKING PP ON RANK 2
	60	;PP TO OR BLOCK PP ON RANK 3
	100	;...
	140
	200	;...
	300	;PP TO OR BLOCK PP ON RANK 7
	400	;TO RANK 8

PWNV==200
NV==640	;3 1/4 P
BV==700	;3 1/2 P
RV==1200	;5 P
KQV==2340	;9 3/4 P
BVMNV==BV-NV
TPCS==2*<RV+BV+NV>+KQV+600	;INITIAL MATERIAL PER SIDE (K=600) EXCEPT PAWNS
TPNS==8.*PWNV	;INITIAL PAWN MATERIAL PER SIE

GDMF:	0	;SAFE MOVE FLAG
LLMGPL==500
LMGPDL:	BLOCK LLMGPL
LGLMST:	0
TEFAL:	0
LMQS:	0
LMJS:	0	;SAVE J AROUND LMG (DIR OF MOVE FOR SLDPC)
LMAS:	0	;SAVE A ROUND LMG (SQ MOVED TO)
CDEVV:	0
CDVCF:	0	;CURRENT DEVEL VAL COMPUTED FLAG
TEFFORT:	0
LMOA:	0
PCBAL:	TPCS	;MATERIAL FOR WHITE
	TPCS	;FOR BLACK
PNBAL:	TPNS	;PAWN MATERIAL FOR W
	TPNS	;FOR B

OPCBAL:	BLOCK 2	;PCBAL AT TOP OF TREE
OPNBAL:	BLOCK 2	;PNBAL AT TOP OF TREE
LMFORS:	0	;NUMBER FORCING POSSIBILITIES 
CPOSV:	0	;VALUE OF CURRENT POSITIONALLY
LMGT1:	0	;TEMP USED IN CAPT SECT OF LMGR
BPCSOP:	0	;BITS SET FOR PIECE ON PREY


OWPNC:	0	;WHITE P CNT AT TOP OF TREE
OBPNC:	0	;B " "
WPNC:	8	;WHITE PAWN COUNT
BPNC:	8	;BLACK PAWN COUNT
WQNC:	1	;WHITE QUEEN COUNT
BQNC:	1	;BLACK QUEEN COUNT
WRKC:	2	;WHITE ROOK COUNT
BRKC:	2	;BLACK ROOK COUNT
WBSC:	2	;WHITE BISHOP COUNT
BBSC:	2	;BLACK BISHOP COUNT
WKNC:	2	;WHITE KNIGHT COUNT
BKNC:	2	;BLACK KNIGHT COUNT
NWKG:	1	;# WHITE KINGS !
NBKG:	1	;# BLACK KINGS!

WLBC:	1	;WHITE BISH ON LIGHT SQ
BLBC:	1	;BLACK BISH ON LIGHT SQ
WDBC:	1	;WHITE BISH ON DARK SQ
BDBC:	1	;BLACK BISH ON DARK SQ

SLBC:	WLBC
	BLBC
	WLBC

SDBC:	WDBC
	BDBC
	WDBC

SPNC:	WPNC
	BPNC
	WPNC

SQNC:	WQNC
	BQNC
	WQNC

SRKC:	WRKC
	BRKC
	WRKC

SBSC:	WBSC
	BBSC
	WBSC

SKNC:	WKNC
	BKNC
	WKNC

SNUOP:	NUMORP
	NUMORP+1
	NUMORP

;SQVAL:	BLOCK BD2

OSPNC:	OWPNC
	OBPNC
	OWPNC

	0	;MUST BE AT PVALUE REF AT CLOSSC
PP PVALUE:,	REPEAT 2,[
	REPEAT 8,PWNV
	RV
	NV
	BV
	3000
	KQV
	BV
	NV
	RV
]

CSQP=.-2*BW
	REPEAT 3*BW,0
	REPEAT 2,[
	REPEAT 4,0
	REPEAT 2,-1
	REPEAT 4,0
]
	REPEAT 3*BW,0

LMRDT:	BW
	1
	-BW
	-1

LMBDT:	BW+1
	BW-1
	-BW-1
	-BW+1

PP LMGT:,	;SIGN SET FOR PAWNS
	IRPS PWC,,LMWPW LMBPW
	REPEAT 8, SETZ PWC
	LMROOK
	LMKNT
	LMBIS
	LMKING
	LMQUEEN
	LMBIS
	LMKNT
	LMROOK

TERMIN


PP LMGSTD:,	;SCORING TALE DIFFERENT ROUTINES FOR SLIDING PIECES
	;SIGN NEG FOR WHITE PAWNS
IRP PWC,,[SETZ LMWPW,LMBPW]
	REPEAT 8,PWC
	LSROOK
	LMKNT
	LSBIS
	LMKING
	LSQUEEN
	LSBIS
	LMKNT
	LSROOK
	TERMIN

PP SNFBP:,	;SIGN NEG FOR BLACK PAWNS
	REPEAT NPCS,0
	REPEAT 8,SETZ
	REPEAT 8,0

PP PNTB:,	;PIECE TO BIT
	REPEAT NPC,<43-.RPCNT>←12.+100,,BPCSOP

PP DEFVL:,	BLOCK NPC	;VALUE FOR DEFENDING THIS P


PP ENPCL:,	BLOCK NPC	;CALCULATED LOSS IN ENPRISE
			;MUST FOLLOW DEFVL

LMVDST==400
MVDST:	BLOCK LMVDST	;MOVE DESCRIPTION TABLE
;;SYM1

SYMT:	SIXBIT /K/
	SIXBIT /Q/
	SIXBIT /RK/
	SIXBIT /NK/
	SIXBIT /BK/
	SIXBIT /RQ/
	SIXBIT /NQ/
	SIXBIT /BQ/
	SIXBIT /B/
	SIXBIT /N/
	SIXBIT /R/
	SIXBIT /G/
	SIXBIT /PK/
	SIXBIT /PQ/
	SIXBIT /PRK/
	SIXBIT /PNK/
	SIXBIT /PBK/
	SIXBIT /PRQ/
	SIXBIT /PNQ/
	SIXBIT /PBQ/
	SIXBIT /PB/
	SIXBIT /PN/
	SIXBIT /PR/
	SIXBIT /P/
	SIXBIT /O/

;;;SYMT

SYMPS:IFN DSPLY,[
	SIXBIT /SDS/
	SIXBIT /SLS/
]	SIXBIT /DVSP/
	SIXBIT /M/
	SIXBIT /U/
	SIXBIT /DVMS/
	SIXBIT /DB/
	SIXBIT /ES/
	SIXBIT /TESER/
	SIXBIT /GP/
	SIXBIT /WP/
	SIXBIT /BP/
	SIXBIT /SP/
	SIXBIT /NP/
IFN DSPLY,	SIXBIT /YCNAF/
	SIXBIT /TNP/
	SIXBIT /PLLAW/
	SIXBIT /WTES/
	SIXBIT /DTES/
	SIXBIT /FTES/
	SIXBIT /DFTES/
	SIXBIT /CTES/
IFE DEC,	SIXBIT /YTT/
	SIXBIT /WARD/
IFN HSCOD,	SIXBIT /HSAH/
IFE DECTS,	SIXBIT /EMITT/
IFE DECTS,	SIXBIT /ULKKLC/
IFE DECTS,	SIXBIT /MRAPS/
IFN BOOK,	SIXBIT /KOOB/
IFN UTAPE,	SIXBIT /DAERU/
	SIXBIT /DSTES/
	SIXBIT /DSSTES/
IFE DECTS,	SIXBIT /LCTES/
IFN UTAPE,[
	SIXBIT /ELIF/
	SIXBIT /ETIRWU/
	SIXBIT /EVAS/
	SIXBIT /SR/
]	SIXBIT /TOPS/
IFN BOOK,	SIXBIT /KOOBC/
	SIXBIT /ECART/

IFE DECTS,	SIXBIT /WST/
IFN BOOK,	SIXBIT /KOOBR/
	SIXBIT /TSIL/
	SIXBIT /SCB/
	SIXBIT /CPT/
IFN KILLH,	SIXBIT /SHK/
	SIXBIT /SFS/
	SIXBIT /BKOOBW/
	SIXBIT /BKOOBR/
	SIXBIT /SSMS/	;MULTIPLE SEARCH MODE
	SIXBIT /WSCI/	;INCREMENTAL CAT MODE
	SIXBIT /WSALS/
	SIXBIT /SVPS/
	SIXBIT /VDPT/
	SIXBIT /KCOLCI/
	SIXBIT /POTS/
	SIXBIT /RETSAF/
	SIXBIT /REWOLS/
	SIXBIT /WSRAP/
	SIXBIT /ASGNIK/
	SIXBIT /GLA/
	SIXBIT /BDGMP/
	SIXBIT /NAVM/
	SIXBIT /WSSS/
	SIXBIT /WSDFD/
	SIXBIT /WSGCP/
	SIXBIT /YALPER/
	SIXBIT /T/
	SIXBIT /PT/
	SIXBIT /TLLA/
	SIXBIT /DVPTES/
	SIXBIT /RAELC/
	SIXBIT /SOPW/
	SIXBIT /SOPR/
	SIXBIT /TUP/
	SIXBIT /EDIS/
	SIXBIT /TSETES/
	SIXBIT /GDNER/
	SIXBIT /WSGE/
	SIXBIT /SIDBD/
	SIXBIT /WSCF/
	SIXBIT /WSSH/
	SIXBIT /VPH/
	SIXBIT /KSDHR/
	SIXBIT /KSDHW/
	SIXBIT /KSDHVS/
	SIXBIT /NEPOH/
	SIXBIT /DAERH/
	SIXBIT /PIKS/
	SIXBIT /NIPOTS/
	SIXBIT /WSCRH/
	SIXBIT /WSCRAP/
	SIXBIT /PTES/
	SIXBIT /WSQSC/
	SIXBIT /STGOWT/
	SIXBIT /TPBH/
	SIXBIT /WSTCQS/
	SIXBIT /WSNVM/
	SIXBIT /SKWA/
	SIXBIT /WSASMP/
	SIXBIT /WSAS/
	SIXBIT /WSSAC/
	;ADD NEW PSEUDOS HERE ↑

IFN BOOK,[
BKSMS:	SIXBIT /V/
	SIXBIT /E/
	SIXBIT /L/
	SIXBIT /T/
]

NSYMS=.-SYMT

;;SYM2
PTB:
REPEAT 3,[
	BIT 12	
;0   1   2   3   4   5   6  7   8
IFE .RPCNT,PTBQ:
	BIT 13	
;G  KRP KNP KBP KP QP QBP QNP QRP
	BIT 9	
;9   10  11  12  13  14  15  16  
	BIT 10	
;KR  KN  KB  K   Q   QB  QN  QR
	BIT 11
	BIT 16
	BIT 15
	BIT 14
IFE .RPCNT,PTBB:
	BIT 11 14
IFE .RPCNT,PTBN:
	BIT 10 15
IFE .RPCNT,PTBR:
	BIT 9 16
	BIT 0
IFE .RPCNT,PTBP:
	BIT 18 4+
	BIT 18 5+
	BIT 18 1+
	BIT 18 2+
	BIT 18 3+
	BIT 18 8+
	BIT 18 7+
	BIT 18 6+
	BIT  18 60+6+
	BIT 18 40+7+
	BIT 18 20+8+
	BIT 1 2 3 4 5 6 7 8
	BIT 17	
;CASTLE
IFE .RPCNT,PTBL=.-PTB
]

SQTB:	4	;1  2  3  4  5  6  7  8
	5	;KR KN KB K  Q  QB QN QR
	1
	2
	3
	8
	7
	6
	3,,6
	7,,2
	1,,8
	REPEAT 14.,600000,,

;;;SYMTV
PSDS:IFN DSPLY,[
	600000,,DBS1	;4.9 USE STANDARD OUTPUT
	600000,,DBS2	;4.8 USE STANDARD INPUT
]	600000,,PMVS	;IF 4.9 BUT NOT 4.8 VARIABLE IS IN DISP ADR -1
	HACK1
	HACK2
	600000,,MVDS
	PBOARD
	600000,,ECHOS
	ARESET
	APG
	PWHITE
	PBLACK
	PSELF
	PNORM
IFN DSPLY,SETZ FANCY
	SETZ PNT
	SETZ AWALLP
	ASETW
	600000,,HK1V
	600000,,FDCUT
	600000,,FDDCUT
	600000,,CATCUT
IFE DEC,600000,,HEAR
	ADRAW
IFN HSCOD,	600000,,NHSW
IFE DECTS,	ATTIME	;TYPE TIME
IFE DECTS,	600000,,CLKSW	;SWITCH CLOCK KLUDGE ON AND OFF
IFE DECTS,	ASPARM	;STORE PARAMETERS
IFN BOOK,	600000,,UBKF
IFN UTAPE,AUREAD
	600000,,IVVDD	;SET DEPTH OF SECONDARY ANAL
	600000,,INVD	;SET PLYN FROM WHICH SEC ANAL MADE
IFE DECTS,	ASETCL	;SET CLOCK
IFN UTAPE,[
	AFILE
	AWRT
	ASAVE
	ARST
]	ASPOT	;ODDS
IFN BOOK,	ACBOOK
	ATRACE

IFE DECTS,	600000,,TSW
IFN BOOK,	ARBOOK
	ALIST
	600000,,NSBVS
	ATPCG
IFN KILLH,600000,,AKHS
	600000,,FIS
	AWBKB
	ARBKB
	600000,,MSSW	;MULTIPLE SEARCH SWITCH
	600000,,ICSW	;INCREMENTAL CAT SWITCH
	600000,,LNSW
	600000,,PPVSW
	ATPCC
	600000,,INVCLK
	ASTOP
	AFASTER
	ASLOWER
	600000,,PARSW
	600000,,KINGSW
	600000,,ALGSW
	600000,,PMDDSW
	600000,,MVANSW
	600000,,SSSW
	600000,,DFDSW
	600000,,PCGSW
	AREPLAY
	ATRACE
	APTRCE
	ALTRCE
	600000,,RPVD
	ACLEAR
	AWPOS
	ARPOS
	APUT
	ASIDE
	ASTEST
	EGREAD
	600000,,EGSW
	600000,,DBDSSW
	600000,,FCSW
	400000,,HSSW+1	;CROCK
	AHPV
	ARHDSK
	AWHDSK
	ASVHDK
	ARDBB	;HOPEN
	HFILER	;HREAD
	ASKIP
	ASTPIN
	600000,,HRCSW
	600000,,PARCSW
	ASETP
	600000,,CSQSW
	600000,,TWOGTS
	AHBPT
	600000,SQCTSW
	600000,,MVNSW
	400000,,AUXTTY
	600000,,PMSASW
	600000,,SASW
	600000,,CASSW
	;ADD NEW PSEUDOS HERE ↑

IFN BOOK,[
	BKV	;VARIATION NAME
	BKE	;POP 1
	BKM	;POP MULTIPLE
	BKT	;TRANSPOSITION
]

IFN .-SQTB-NSYMS,[PRINTC /SYM TAB LOSSAGE!
/]



PDL:	BLOCK PDLL

SQN:	0
TAKES:	0
TAKES1:	0
TAKES2:	0
EQSGNF:	0
RNPCS:	0
RNSQS:	0
GME:	0
LGLMV:	0
SIDE:	NPCS
CASLF:	0
PLYN:	0
	-1	;FOR APUT
GAME:	BLOCK LGAME	;MOVE
IFN HSCOD,[
GHK1:	BLOCK LGAME	;HASH KEY THIS POSITION
]
GAMEV:	BLOCK LGAME	;VALUE OF POSITION OR SETZ IF MOVE TYPED IN OR BOOK
GAMP:	GAME-1
GSYLNF:	0
GSYLMF:	0

	777776,,
	-1
SYLT:	BLOCK 5

;;;MCAF

MCAF:	;RECALC WPCOR BPCOR AT SQUARE IN A AND SIMUL ATEVL DOES NOT CLOBBER S
	CLEARM WPCOR(A)	;CLEAR PIECE WORDS
	CLEARM BPCOR(A)
	SETOM BPCHD(A)	;RESET CHANGED INDICATOR
	PUSHJ P,ATEVE	;CALC DATA
	CAIL C,DFPCT
	JRST MCAF2
	MOVE T2,ATEVLT(I)
MCAF3:	TLNN T2,770000
	JRST MCAF4
	SKIPGE T1,1(C)
	TRO T1,100
	IDPB T1,T2
	CAIGE C,DFPCT-1
	AOJA C,MCAF3
MCAF2:	CAIL D,ATPCT
	JRST MCAF5
	MOVE T2,ATEVLT+1(I)
MCAF6:	TLNN T2,770000
	JRST MCAF7
	SKIPGE T1,1(D)
	TRO T1,100
	IDPB T1,T2
	CAIGE D,ATPCT-1
	AOJA D,MCAF6
MCAF5:	MOVE T1,[MCFMSK]
	ANDCAM T1,CNTRL(A)	;CLEAR IT EXCEPT FOR OBSQP
	SKIPN WA(A)
	JRST MSQC1	;NOT CONTESTED BY WHITE
	SKIPN BA(A)
	JRST MSQC2	;NOT CONTESTED BY BLACK
	LDB T1,[340600,,WPCOR(A)]
	LDB T2,[340600,,BPCOR(A)]
	MOVE ZR,PVALUE(T1)
	CAMN ZR,PVALUE(T2)
	JRST MSQC4	;LEAST VAL PCS EVEN
	CAML ZR,PVALUE(T2)
	JRST MSQC5	;BLACK HAS SMALLEST
	MOVE ZR,BA(A)	;WHITE HAS SMALLEST
	SOJN ZR,MSQC8A	;BLACK HAS MORE THAN 1
	MOVE ZR,WA(A)
	MOVEI C,MSQWSC
	SOJN ZR,MSQC7	;XFER ON WHITE HAS 2 OR MORE
	MOVEI C,MSQWD
	JRST MSQC7

MSQC1:	MOVEI C,MSQUC
	SKIPN BA(A)
	JRST MSQCX	;UNCONTESTED BY EITHER
	LDB T1,[111700,,BPAS(A)]
	SKIPN T1
	SKIPA C,[MSQBD]	;ATT ONLY BY P
	MOVEI C,MSQBUC
MSQC6:	LDB T2,[340600,,BPCOR(A)]	;CREDIT LEAST BLACK PC AND EXIT
	DPB T2,[BCTLF,,CNTRL(A)]
	JRST MSQCX

MSQC8A:	MOVE D,WA(A)
	CAIL ZR,-1(D)
	SKIPA C,[MSQWD]
MSQC7B:	MOVEI C,MSQWC
	JRST MSQC7

MSQC4:	MOVEI C,MSQE
	MOVE ZR,WA(A)
	SKIPL LMGT(T1)	;SKIP ON LEAST VAL PC IS P
	CAMN ZR,BA(A)
	JRST MSQCX
	CAMG ZR,BA(A)
	JRST MSQC6B
	JRST MSQC7B

MSQC2:	LDB T1,[111700,,WPAS(A)]
	SKIPN T1
	SKIPA C,[MSQWD]	;ATT ONLY BY P
	MOVEI C,MSQWUC
MSQC7:	LDB T2,[340600,,WPCOR(A)]	;CREDIT LEAST WHITE PC AND EXIT
	DPB T2,[WCTLF,,CNTRL(A)]
	JRST MSQCX

MSQC5:	MOVE ZR,WA(A)
	SOJN ZR,MSQC5A
	MOVE ZR,BA(A)
	MOVEI C,MSQBSC
	SOJN ZR,MSQC6
	MOVEI C,MSQBD
	JRST MSQC6


MSQC5A:	MOVE D,BA(A)
	CAIL ZR,-1(D)
	SKIPA C,[MSQBD]
MSQC6B:	MOVEI C,MSQBC
	JRST MSQC6

MSQCX:	DPB C,[BSQSP,,CNTRL(A)]
	MOVE C,DFPCP
	MOVE D,ATPCP
	MOVE TT,NATKS
	POPJ P,

MCAF4:	MOVSI T2,(SETZ)
	IORM T2,@ATEVLT(I)
	JRST MCAF2

MCAF7:	MOVSI T2,(SETZ)
	IORM T2,@ATEVLT+1(I)
	JRST MCAF5
SQCAF:	MOVE T1,WA(A)	;COMPUTE SQ CNTRL AFTER PC IN B ATTS (IT IS KNOWN NOT TO BE ATTACKING NOW)
	MOVE T2,BA(A)	;AND PC IN S GOES AWAY (WHICH MAY OR MAY NOT BE ATTACKING SQ ORIGIONALLY)
	LDB Q,[340600,,WPCOR(A)]	;IN EITHER CASE 0 = NULL
	LDB J,[340600,,BPCOR(A)]
	CLEARM SQCWI
	CLEARM SQCBI
	JUMPN S,SQCAF3
SQCAF5:	MOVEI C,100000
	MOVEI D,100000
	SKIPE Q
	MOVE C,PVALUE(Q)
	SKIPE J
	MOVE D,PVALUE(J)
	JUMPE B,SQCAF1
	MOVE ZR,PASIN(B)
	SKIPGE PIECE(B)
	AOJA T2,SQCAF2
	ADDM ZR,SQCWI
	CAMG C,PVALUE(B)
	AOJA T1,SQCAF1
	HRRZ Q,B
	MOVE C,PVALUE(B)
	AOJA T1,SQCAF1

SQCAF2:	ADDM ZR,SQCBI
	CAMG D,PVALUE(B)
	JRST SQCAF1
	HRRZ J,B
	MOVE D,PVALUE(J)
SQCAF1:	JUMPE T1,SQC1	;NOT CONTESTED BY W
	JUMPE T2,SQC2	;NOT CONTESTED BY B
	CAMN C,D
	JRST SQC4	;LEAST VAL PCS EVEN
	CAML C,D
	JRST SQC5	;BLACK HAS SMALLEST
	SOJN T2,SQC8A	;BLACK HAS MORE THAN 1
	MOVEI TT,MSQWSC
	SOJN T1,SQCX	;XFER ON WHITE HAS 2 OR MORE
	MOVEI TT,MSQWD
	JRST SQCX

SQCAF3:	SKIPGE PIECE(S)
	JRST SQCAF4
	MOVE ZR,[430700,,WPCOR(A)]
SQCAF7:	ILDB TT,ZR
	JUMPE TT,SQCAF5
	TRZ TT,100
	CAMN TT,S
	JRST SQCAF6
	TLNE ZR,770000
	JRST SQCAF7
	JRST SQCAF5	;DOESNT BEAR

SQCAF6:	CAMN Q,S
	LDB Q,[250600,,WPCOR(A)]
	MOVN ZR,PASIN(S)
	ADDM ZR,SQCWI
	SOJA T1,SQCAF5

SQCAF4:	MOVE ZR,[430700,,BPCOR(A)]
SQCAF8:	ILDB TT,ZR
	TRZ TT,100
	JUMPE TT,SQCAF5
	CAMN TT,S
	JRST SQCAF9
	TLNE ZR,770000
	JRST SQCAF8
	JRST SQCAF5

SQCAF9:	CAMN J,S
	LDB J,[250600,,BPCOR(A)]
	MOVN ZR,PASIN(S)
	ADDM ZR,SQCBI
	SOJA T2,SQCAF5

SQC1:	MOVEI TT,MSQUC
	JUMPE T2,SQCX	∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈∧␈BIT
	MOVE T2,PVALUE(T1)
	JUMPE B,EPP3
	CAMGE T2,PVALUE(B)
	JRST EPP3	;DIRECT ATTACKING LESS VAL
EPP1:	JUMPE B,EPP7A	;ATTACKERS EXAUSTED
	IDPB B,EPPCPP	;STORE IN CAPTURED ATTACKER BUFFER
	SUB S,PVALUE(B)	;EXPEND EXTRA ATTACKER
EPP4A:	MOVE B,EPBPC1
	CLEARM EPBPC1
EPP4:	CAMLE S,MCT4T4	;COMPARE WITH DEFS BEST OPTION SO FAR
	MOVE S,MCT4T4	;HE WONT LET US GET HERE
	CAMLE S,MCT4T2
	MOVEM S,MCT4T2	;ATTACKERS BEST CHOICE SO FAR
	CAMN S,MCT4T4
	JRST EPP7	;ISSUE RESOLVED
EPPP3:	TLNN C,770000
	JRST EPP6	;NO MORE DEFENDERS
	ILDB T1,C
	JUMPE T1,EPP6	;NO MORE DEFENDERS
	TRZ T1,100	;IGNORE UNBLOCKED BIT
	CAMN T1,EPPIP
	JRST EPPP3
	SKIPE TT,PINT(T1)
	JRST EPPP1	;HONOR PIN?
EPPP2:	SKIPE TT,SPINT(T1)
	JRST EPC1	;HONOR CONSTRAINT?
EPC2:	SKIPE TT,NHC
	JRST EPHC1	;DID THIS PC FIGURE IN TRADE OFF OF MAIN MV?
EPHC2:	IDPB T1,EPPDPP
	MOVE T2,S
	CAMGE T2,MCT4T2	;GIVE HIM AT LEAST WHAT HE HAD
	MOVE T2,MCT4T2
	MOVEM T2,MCT4T5
	ADD S,PVALUE(T1)	;EXPEND NEXT DEFENDER
	JUMPLE S,EPP7	;NOT E.P. IF HE LETS US GET HERE, NOT E.P. UNLESS HE HAD BETTER OPTION EARLIER
	CAMGE S,MCT4T2	;SEE IF ATTACKER HAD BETTER OPTION EARLIER
	MOVE S,MCT4T2	;YES ATTACKER WONT LET US GET HERE
	CAMGE S,MCT4T4
	MOVEM S,MCT4T4	;SEE IF BEST DEFENDERS CHOICE SO FAR
	CAMN S,MCT4T2
	JRST EPP7	;ISSUE RESOLVED
	JRST EPP5

EPPP1:	HRRZ ZR,(TT)
	JUMPN ZR,EPPP3	;MULT PIN, HONOR
	LDB ZR,[BPDPB,,1(TT)]
	JUMPN ZR,EPPP3	;PIN BY DOUBLED PCS, HONOR
	LDB ZR,[PINATP,,1(TT)]	;PINNING PC CAPTURED?
	PUSHJ P,EPACP
	JRST EPPP2	;PINNING PC CAPTED, IGNORE PIN
	JRST EPPP3	;PIN HOLDS, FLUSH PC

EPACP:	MOVE T2,[440700,,EPPCPB]	;ATTACKING PC IN ZR CAPTED?
	MOVEM T2,EPPCPT
EPPP4:	ILDB T2,EPPCPT
	JUMPE T2,POPJ1	;NO
	CAME ZR,T2
	JRST EPPP4
	POPJ P,	;YES IGNORE PIN

EPDCP:	MOVE T2,[440700,,EPPCPD]
	MOVEM T2,EPPCPT
EPDC1:	ILDB T2,EPPCPT
	JUMPE T2,POPJ1
	CAME ZR,T2
	JRST EPDC1
	POPJ P,

EPP3:	IDPB T1,EPPCPP
	SUB S,T2	;EXPEND NEXT DIRECT ATTACKER
	TLNN D,770000	;ONLY CONSIDER FIRST 5 ATTACKERS
	MOVEI D,0
	IBP D
	JRST EPP4

EPP3A:	TLNN D,770000
	MOVEI D,0
	IBP D
	JRST EPP5A

EPP7A:	MOVE S,MCT4T5	;ATTACKER CANT REALLY MAKE LAST CAPT
	CAMGE S,MCT4T4
	MOVEM S,MCT4T4
	JRST EPP7

EPP6:	MOVE S,MCT4T3	;DEF COULD NOT REALLY MAKE LAST RECAPT
	CAMGE S,MCT4T2	;TEST IF THIS CHOICE BETTER THAN ATTACKERS OTHER OPTIONS
EPP7:	MOVE S,MCT4T2	;ATTACKERS BEST CHOICE
	CAMLE S,MCT4T4
	MOVE S,MCT4T4	;DEFENDER CAN MINIMIZE LOSSES BY NOT GOING ALL THE WAY
	MOVE B,EPPEPC
	POP P,TT
	POPJ P,

EPBP1:	MOVNI D,1
	SKIPGE PIECE(B)
	JRST EPBP4
	CAIN A,BW-1(C)
	MOVEI D,4
	CAIN A,BW+1(C)
	MOVEI D,5
EPBP5:	JUMPL D,EPBP3
EPBP2:	LDB T1,RDATS(D)
	JUMPE T1,EPBP3
	SKIPL SLDPC(T1)
	JRST EPBP3
	MOVE T2,PIECE(T1)
	XOR T2,PIECE(B)
	JUMPL T2,EPBP3
	MOVEM T1,EPBPC
	MOVEM T1,EPBPC1
	JRST EPBP3

EPBP4:	CAIN A,-BW+1
	MOVEI D,6
	CAIN A,-BW-1
	MOVEI D,7
	JRST EPBP5

EPC1:	LDB T2,[SPINSQ,,(TT)]	;HONOR CONSTRAINT?
	CAMN T2,A
	JRST EPC3	;CONSTRAINT TO THIS SQ
	MOVE ZR,BOARD(T2)
	JUMPE ZR,EPC5
	SUBI ZR,PIECE
	PUSHJ P,EPDCP
	JRST EPC3	;PC CONSTRAINED TO GONE
EPC5:	LDB ZR,[SPINCP,,1(TT)]
	JUMPE ZR,EPC4
	CAMN ZR,PCMVNG
	JRST EPC5A	;PC CAUSING CONSTRAINT MOVING IN MAIN MV (RELEASING CONSTRAINT?)
	PUSHJ P,EPACP
	JRST EPC3	;PC CAUSING CONSTRAINT GONE
EPC4:	LDB ZR,[PTID,,PIECE(T1)]
	SOJLE ZR,EPPP3	;P OR N WONT HOLD FLUSH PC
	MMSAVAC
	MOVE B,T1
	LDB S,[SPINSQ,,(TT)]
	CLEARM CCANF1
	PUSHJ P,@LGLMPT(B)
	SETOM CCANF1	;DIDNT HOLD
	MMRSAC
	SKIPGE CCANF1
	JRST EPPP3
EPC3:	LDB TT,[SPNLK,,1(TT)]
	JUMPN TT,EPC1
	JRST EPC2

EPHC1:	CAMN T1,CLACLP-1(TT)
	JRST EPHC3
	SOJG TT,EPHC1
	JRST EPHC2

EPHC3:	SKIPGE HCL
	CAME TT,NHC
	JRST EPPP3	;ITS FLUSHED
	LDB ZR,[PTID,,PIECE(T1)]	;IT CAPTED LAST, CAN IT GET BACK?
	SOJLE ZR,EPPP3	;P OR N, NO
	MMSAVAC
	MOVE B,T1
	MOVE S,LMAS
	CLEARM CCANF1
	PUSHJ P,@LGLMPT(B)
	SETOM CCANF1
	MMRSAC
	SKIPGE CCANF1
	JRST EPPP3
	JRST EPHC2


EPC5A:	MOVE T2,ZR
	LDB ZR,[PTID,,PIECE(T2)]
	SOJLE ZR,EPC3
	MOVEI T2,MVDST	;CONSTRAINT CAUSED BY MOVING PC
EPC5A1:	CAML T2,MVDMF
	JRST EPC4
	LDB ZR,[MVDCD,,(T2)]
	SKIPL (T2)
	CAIE ZR,MVDRLA
	JRST EPC5A2
	LDB ZR,[MVDSQ,,(T2)]
	MOVEM ZR,EPC5T1
	LDB ZR,[SPINSQ,,(TT)]
	CAMN ZR,EPC5T1
	JRST EPC3	;RELIEVING CONSTRAINT
EPC5A2:	ADDI T2,NWMVE
	JRST EPC5A1

EPC5T1:	0

;;CAT
DEFINE ATA
	XCT RMINS(I)
	XCT AT(I)
	XCT PASI(I)
	CLEARM BPCHD(A)
TERMIN

DEFINE ATAS
	XCT RMINS(I)
	XCT ATS(I)
	XCT PASI(I)
	CLEARM BPCHD(A)
TERMIN

CAT:	;CALCULATE ATTACKS
	;COMPUTE, AS A FUNCTION OF THE CURRENT POSITION, THE DATA BASE
	;USED BY THE PLAUSIBLE MOVE GENERATOR AND STATIC BOARD EVALUATOR
.CAT:	SKIPLE B,ICSW
	POPJ P,	;USE I C CAT
	JUMPL B,CATC	;CHECK MODE
.CAT1:	AOS NCAT	;ENTRY TO IGNORE INCREMENTAL MODE
	PUSH P,I
	PUSH P,R
	PUSH P,T
	PUSH P,J
IFN HSCOD,	PUSHJ P,HSKG	;CALCULATE HASH KEY
	MOVEI ZR,100.
	MOVEM ZR,CATSCC	;RESET SPOT CHECK COUNT
	MOVE T,[-LPINTB,,PINTB]


IRP X,,[BDBLK,BDA1,BDA2,BDA3,BA,WA,ONEB1,ONEB2,WPAS,BPAS,BPCHD,CNTRL,NWK,NBK]	;CLEAR DATA BASE ARRAYS
IFSN X,BDBLK,	SETZM X+2*BW
IFSE X,BDBLK,	CLEARB I,X+2*BW
	MOVE A,[X+2*BW,,X+2*BW+1]
	BLT A,X+2*BW+8*BW-2
	TERMIN
IRP X,,[PPASED,PPTP]
	SETZM X+1
	MOVE A,[X+1,,X+1+1]
	BLT A,X+8+1
	SETZM X+NPCS+1
	MOVE A,[X+NPCS+1,,X+NPCS+1+1]
	BLT A,X+NPCS+1+8
	TERMIN
	MOVE A,[WPNFLS-1,,WPNFLS]
	BLT A,PINT+NPC-1+1
	MOVE A,[WDPRK,,WDPRK+1]
	BLT A,WDPRK+9
	MOVE A,[BDPRK,,BDPRK+1]
	BLT A,BDPRK+9
	MOVEI A,PINDT-1
	MOVEM A,PINFS
	PUSHJ P,ATEV

	MOVE B,[-NPCS,,1]
MCAT1:	MOVE R,PCATV(B)
	MOVEI W,0
	MOVE J,PASIN(B)
	SKIPE A,PIECEL(B)
	PUSHJ P,@PIECE(B)
	MOVEM W,PDV(B)
	AOBJN B,MCAT1	;LOOP FOR ALL WHITE PCS
	HRLI B,-NPCS	;RIGHT HALF UNCHANGED
	MOVEI I,1	;SET UP FOR BLACK PCS
MCAT2:	MOVE R,PCATV(B)
	MOVEI W,0
	MOVE J,PASIN(B)
	SKIPE A,PIECEL(B)
	PUSHJ P,@PIECE(B)
	MOVEM W,PDV(B)
	AOBJN B,MCAT2
MCAT3:	CAMN T,[-LPINTB,,PINTB]
	JRST MCAT3A
	PUSHJ P,MCAT4	;EXAMINE POSSIBLE PIN
	JRST MCAT3
MCAT3A:
	MOVE B,[-8,,1]
MCAT8:	PUSHJ P,WPBAK
	AOBJN B,MCAT8
	MOVE B,[-8,,NPCS+1]
MCAT9:	PUSHJ P,BPBAK
	AOBJN B,MCAT9
MCATGZ:	SKIPE NWPPP
	PUSHJ P,WPPAC
	SKIPE NBPPP
	PUSHJ P,BPPAC
	POP P,J
	POP P,T
	POP P,R
	POP P,I
CPOPJ:	POPJ P,


WPBAK:	SKIPE A,PIECEL(B)
	SKIPL LMGT(B)	;SKIP ON NOT QUEENED
	JRST MCAT81
	SKIPE PPTP(B)
	JRST MCAT81	;ALREADY KNOWN TO BE P DEF BY P
	LDB T1,[BFILE,,BPREL(A)]
	SKIPN WPNFLS-1(T1)
	SKIPE WPNFLS+1(T1)
	JRST MCAT82
	MOVEI T2,3	;ISOLATED PAWN
MCAT80:	MOVEM T2,PPTP(B)
MCAT81:	POPJ P,

BPBAK:	SKIPE A,PIECEL(B)
	SKIPL LMGT(B)
	JRST MCAT91
	SKIPE PPTP(B)
	JRST MCAT91
	LDB T1,[BFILE,,BPREL(A)]
	SKIPN BPNFLS-1(T1)
	SKIPE BPNFLS+1(T1)
	JRST MCAT92
	MOVEI T2,3
MCAT90:	MOVEM T2,PPTP(B)
MCAT91:	POPJ P,


MCAT82:	SETZB C,D
	SKIPG T1,BOARD-1(A)
	JRST .+3
	SKIPGE LMGSTD-PIECE(T1)
	JRST MCAT84
	SKIPG T1,BOARD+1(A)
	JRST .+3
	SKIPGE LMGSTD-PIECE(T1)
MCAT84:	TRO D,1	;WILL BE DEFENDED IF ADVANCED
	SKIPLE T1,BOARD+BW(A)
	CAIGE T1,BPIECE
	XCT WBKPT1(D)	;ADV NOT BLOCKED
	IOR C,D	;ADV BLOCKED
	TRNE C,1
	JRST MCAT81	;NOT BACK IF BOTH BLOCKED+WOULD BE DEF SINCE HIS PIECE ATTACKED
	LDB T2,[BRANK,,BPREL(A)]
	JRST @WPDIS-2(T2)	;C=0 UNLESS P BLOCKED BY OPPOSITION IN WHICH CASE 1.1 MEANS
				;WOULD BE DEF IF COULD BE ADV 3.1==0
				;IF P BLOCKED, C=D, IF NOT 3.1 OF D SET ALL ELSE CLEAR


WPDIS:	MCT8.2
	MCAT8B
	MCT8.4
	MCT8.4
	MCT8.4
	MCT8.4

MCT8.2:	TLZN D,1	;BLOCKED BY OPPONENT AT RANK 3
	JRST MCAT8B
	SKIPG T1,BOARD+BW-1(A)	;WILL BE DEFENDED IF DOUBLE ADVANCED
	JRST .+3
	SKIPGE LMGSTD-PIECE(T1)
	JRST MCAT8A
	SKIPLE T1,BOARD+BW+1(A)
	SKIPL LMGSTD-PIECE(T1)
	JRST MCAT8B
MCAT8A:	SKIPG T1,BOARD+2*BW(A)
	JRST .+3
	CAIL T1,BPIECE
	JRST MCAT8B	;BLOCKED BY OPPONENT AT RANK 4
	SKIPLE T1,BOARD+2*BW+1(A)
	SKIPL SNFBP-PIECE(T1)
	JRST .+2
	JRST MCAT8B	;BACKWARD DUE TO EP CAPTURE
	SKIPLE T1,BOARD+2*BW-1(A)
	SKIPL SNFBP-PIECE(T1)
	JRST MCAT81
	JRST MCAT8B

WBKPT1:	TLOA D,1
	JRST MCAT81

MCAT8B:	MOVEI T2,2	;BACKWARD
	JRST MCAT80

MCT8.4:	SKIPLE T1,BOARD-2*BW+1(A)	;WILL BE DEFENDED BY ADVANCE OF ADJACENT PAWN
	SKIPL LMGSTD-PIECE(T1)
	JRST MCT84.
	SKIPLE T1,BOARD-BW+1(A)	;THAT  PAWNBLOCKED BY OPPONENT
	CAIGE T1,BPIECE
	JRST MCAT81
MCT84.:	SKIPLE T1,BOARD-2*BW-1(A)
	SKIPL LMGSTD-PIECE(T1)
	JRST @WPDIS2-4(T2)
	SKIPLE T1,BOARD-BW-1(A)
	CAIGE T1,BPIECE
	JRST MCAT81
	JRST @WPDIS2-4(T2)	;AT TIME OF DISP IT IS KNOWN THAT P IS
				; NOT PDP, NOT ISO, NOT (WOULD BE DEF
				;BY SINGLE PUSH OF ADJ P AND THAT P NOT BLOCKED)


WPDIS2:	MT8.4A	;FOURTH ROW BACKWARD UNLESS ADJ PAWN BLOCKED
	MCT8.5
	MCT8.6
	MCAT8F

MT8.4A:	SKIPG T1,BOARD-2*BW+1(A)
	JRST MT8.4B
	SKIPGE LMGSTD-PIECE(T1)
	JRST MCAT8F	;PAWN MUST BE BLOCKED SO THIS P IS F
MT8.4B:	SKIPLE T1,BOARD-2*BW-1(A)
	SKIPL LMGSTD-PIECE(T1)
	JRST MCAT8B
	JRST MCAT8F

MCT8.5:	SKIPLE T1,BOARD-3*BW+1(A)	;WILL BE DEFENDED BY DOUBLE ADVANCE OF ADJACENT PAWN
	SKIPL LMGSTD-PIECE(T1)
	JRST MCAT8X
	SKIPG T1,BOARD-2*BW+1(A)	;BLOCKED BY OPPONENT AT RANK 3
	JRST .+3
	CAIL T1,BPIECE
	JRST MCAT8X
	SKIPLE T1,BOARD-BW+1(A)	;BLOCKED BY OPPONENT AT RANK 4
	CAIGE T1,BPIECE
	JRST MCAT81	;NOT BLOCKED OR BLOCKED BY OUR PIECE
MCAT8X:	SKIPLE T1,BOARD-3*BW-1(A)
	SKIPL LMGSTD-PIECE(T1)
	JRST MCAT8Y
	SKIPG T1,BOARD-2*BW-1(A)
	JRST .+3
	CAIL T1,BPIECE
	JRST MCAT8Y
	SKIPLE T1,BOARD-BW-1(A)
	CAIGE T1,BPIECE
	JRST MCAT81
MCAT8Y:	SKIPG T1,BOARD+BW+1(A)	;BACKWARD OR FORWARD
	JRST .+3
	SKIPGE LMGSTD-PIECE(T1)
	JRST MCAT8B
	SKIPG T1,BOARD+BW-1(A)
	JRST .+3
	SKIPGE LMGSTD-PIECE(T1)
	JRST MCAT8B
	SKIPG T1,BOARD+2*BW+1(A)
	JRST .+3
	SKIPGE LMGSTD-PIECE(T1)
	JRST MCAT8B
	SKIPG T1,BOARD+2*BW-1(A)
	JRST MCAT8F
	SKIPGE LMGSTD-PIECE(T1)
	JRST MCAT8B
MCAT8F:	AOS PPTP(B)	;FORWARD
	JRST MCAT81

MCT8.6:	SKIPG T1,BOARD+BW+1(A)	;BACKWARD OR FORWARD
	JRST .+3
	SKIPGE LMGSTD-PIECE(T1)
	JRST MCAT8B
	SKIPG T1,BOARD+BW-1(A)
	JRST MCAT8F
	SKIPGE LMGSTD-PIECE(T1)
	JRST MCAT8B
	JRST MCAT8F

MCAT92:	SETZB C,D
	SKIPG T1,BOARD-1(A)	;WILL BE DEFENDED IF ADVANCED
	JRST .+3
	SKIPGE SNFBP-PIECE(T1)
	JRST MCAT94
	SKIPG T1,BOARD+1(A)
	JRST .+3
	SKIPGE SNFBP-PIECE(T1)
MCAT94:	TRO D,1
	SKIPLE T1,BOARD-BW(A)	;ADVANCE BLOCKED
	CAIL T1,BPIECE
	XCT BBKPT1(D)
	IOR C,D
	TRNE C,1
	JRST MCAT91
	LDB T2,[BRANK,,BPREL(A)]
	JRST @BPDIS-2(T2)

BPDIS:	MCT9.4
	MCT9.4
	MCT9.4
	MCT9.4
	MCAT9B
	MCT9.2

MCT9.2:	TLZN D,1	;BLOCKED BY OPPONENT AT RANK 3
	JRST MCAT9B
	SKIPG T1,BOARD-BW-1(A)	;WILL BE DEFENDED IF DOUBLE ADVANCED
	JRST .+3
	SKIPGE SNFBP-PIECE(T1)
	JRST MCAT9A
	SKIPLE T1,BOARD-BW+1(A)
	SKIPL SNFBP-PIECE(T1)
	JRST MCAT9B
MCAT9A:	SKIPG T1,BOARD-2*BW(A)
	JRST .+3
	CAIGE T1,BPIECE
	JRST MCAT9B	;BLOCKED BY OPPONENT AT RANK 4
	SKIPLE T1,BOARD-2*BW+1(A)	;BACKWARD DUE TO EP CAPTURE
	SKIPL LMGSTD-PIECE(T1)
	JRST .+2
	JRST MCAT9B
	SKIPLE T1,BOARD-2*BW-1(A)
	SKIPL LMGSTD-PIECE(T1)
	JRST MCAT91
	JRST MCAT9B

BBKPT1:	TLOA D,1
	JRST MCAT91

MCAT9B:	MOVEI T2,2
	JRST MCAT90

MCT9.4:	SKIPLE T1,BOARD+2*BW+1(A)	;WILL BE DEFENDED BY ADVANCE OF ADJACENT PAWN
	SKIPL SNFBP-PIECE(T1)
	JRST MCT94.
	SKIPLE T1,BOARD+BW+1(A)	;BLOCKED BY OPPONENT
	CAIL T1,BPIECE
	JRST MCAT91
MCT94.:	SKIPLE T1,BOARD+2*BW-1(A)
	SKIPL SNFBP-PIECE(T1)
	JRST BPDIS2-2(T2)
	SKIPLE T1,BOARD+BW-1(A)
	CAIL T1,BPIECE
	JRST MCAT91
	JRST BPDIS2-2(T2)

BPDIS2:	JRST MCAT9F
	JRST MCT9.6
	JRST MCT9.5
	SKIPG T1,BOARD+2*BW+1(A)	;REACHED BY DISP
	JRST MT9.4A
	SKIPGE SNFBP-PIECE(T1)
	JRST MCAT9F
MT9.4A:	SKIPLE T1,BOARD+2*BW-1(A)
	SKIPL SNFBP-PIECE(T1)
	JRST MCAT9B
	JRST MCAT9F

MCT9.5:	SKIPLE T1,BOARD+3*BW+1(A)	;WILL BE DEFENDED BY DOUBLE ADVANCE OF ADJACENT PAWN
	SKIPL SNFBP-PIECE(T1)
	JRST MCAT9X
	SKIPG T1,BOARD+2*BW+1(A)	;BLOCKED BY OPPONENT AT RANK 3
	JRST .+3
	CAIGE T1,BPIECE
	JRST MCAT9X
	SKIPGE T1,BOARD+BW+1(A)	;BLOCKED BY OPPONENT AT RANK 4
	CAIL T1,BPIECE
	JRST MCAT91
MCAT9X:	SKIPLE T1,BOARD+3*BW-1(A)
	SKIPL SNFBP-PIECE(T1)
	JRST MCAT9Y
	SKIPG T1,BOARD+2*BW-1(A)
	JRST .+3
	CAIGE T1,BPIECE
	JRST MCAT9Y
	SKIPLE T1,BOARD+BW-1(A)
	CAIL T1,BPIECE
	JRST MCAT91
MCAT9Y:	SKIPG T1,BOARD-BW+1(A)	;BACKWARD OR FORWARD
	JRST .+3
	SKIPGE SNFBP-PIECE(T1)
	JRST MCAT9B
	SKIPG T1,BOARD-BW-1(A)
	JRST .+3
	SKIPGE SNFBP-PIECE(T1)
	JRST MCAT9B
	SKIPG T1,BOARD-2*BW+1(A)
	JRST .+3
	SKIPGE SNFBP-PIECE(T1)
	JRST MCAT9B
	SKIPG T1,BOARD-2*BW-1(A)
	JRST MCAT9F
	SKIPGE SNFBP-PIECE(T1)
	JRST MCAT9B
MCAT9F:	AOS PPTP(B)
	JRST MCAT91

MCT9.6:	SKIPG T1,BOARD-BW+1(A)	;BACKWARD OR FORWARD
	JRST .+3
	SKIPGE SNFBP-PIECE(T1)
	JRST MCAT9B
	SKIPG T1,BOARD-BW-1(A)
	JRST MCAT9F
	SKIPGE SNFBP-PIECE(T1)
	JRST MCAT9B
	JRST MCAT9F

WPPSD:	LDB T1,[BFILE,,BPREL(A)]	;CHECK IF WP IN B AT SQ A PASSED ALSO AOS WPNFLS + WNPNFL AS APPROPRIATE
	AOS WPNFLS(T1)
	LDB C,[BRANK,,BPREL(A)]
	CAMGE C,WDPRK(T1)
	MOVEM C,WDPRK(T1)
IRP X,,[,+1,-1]	;IS IT PASSED?
	SKIPE C,@PPT+NPCS!X(B)
	CAIGE C,BW-1(A)
	JRST .+5
	LDB D,[BFILE,,BPREL(C)]
	SUB D,T1
	MOVMS D
	SOJLE D,NOTPPW
	TERMIN
	LDB C,[BRANK,,BPREL(A)]
	MOVEI D,BW(A)
	SETZM MMPWNF
MMWPPL:	CAIL C,7
	JRST MMPPW
	SKIPG T2,BOARD(D)
	JRST MMWPL2
	SKIPGE SNFBP-PIECE(T2)
	JRST NOTPPW
	SKIPGE LMGSTD-PIECE(T2)
	SETOM MMPWNF
MMWPL2:	IRP X,,[+1,-1]
	SKIPLE T2,BOARD!X(D)
	SKIPL SNFBP-PIECE(T2)
	JRST .+2
	JRST NOTPPW
	TERMIN
	ADDI D,BW
	AOJA C,MMWPPL

MMPPW:	LDB T2,[BRANK,,BPREL(A)]	;MARK PASSED PAWN
	CAMLE T2,WPPRK(T1)
	MOVEM T2,WPPRK(T1)
	AOS NWPPP
	SKIPE MMPWNF
	TLO T2,400000
	MOVEM T2,PPASED(B)
	JRST .+2
NOTPPW:	AOS WNPNFL(T1)
	SKIPLE T1,BOARD-BW+1(A)	;SEE IF DEFENDED BY PAWN
	SKIPL LMGSTD-PIECE(T1)
	JRST .+2
	JRST MMWPDP
	SKIPLE T1,BOARD-BW-1(A)
	SKIPL LMGSTD-PIECE(T1)
	JRST .+2
MMWPDP:	SETOM PPTP(B)
	POPJ P,

MMWPWN:	PUSHJ P,WPPSD
PTPWP:
RMWP:	PUSH P,A
WPAS1:	ADDM J,WPAS+BW-1(A)
	ADDM J,WPAS+BW+1(A)
	ADDI A,BW
	SKIPL BOARD+BW(A)
	JRST WPAS1
	POP P,A
	ASH J,3
	ADDM J,WPAS+2*BW-1(A)
	ADDM J,WPAS+2*BW+1(A)
	LDB T1,[BRANK,,BPREL(A)]
	CAIE T1,2
	JRST WPAS2
	ADDM J,WPAS+3*BW-1(A)
	ADDM J,WPAS+3*BW+1(A)
WPAS2:	ASH J,3
	ADDM J,WPAS+BW+1(A)
	ADDM J,WPAS+BW-1(A)

	ADDM R,WA+BW+1(A)	;SET UP ATTACKS
	ADD W,WAV+BW+1(A)
	DPB B,[BDALR+BW+1(A)]
	CLEARM BPCHD+BW+1(A)
	ADDM R,WA+BW-1(A)
	ADD W,WAV+BW-1(A)
	DPB B,[BDALL+BW-1(A)]
	CLEARM BPCHD+BW-1(A)
	SKIPL GHSD
	POPJ P,	;NOT BLACK GHOST
	MOVEI T1,BW+1(A)
	CAMN T1,GHLOC
	JRST RMWP1
	MOVEI T1,BW-1(A)
	CAME T1,GHLOC
	POPJ P,
	ADDM R,WA-1(A)
	ADD W,WAV-1(A)
	DPB B,[BDAEPL-1(A)]
	CLEARM BPCHD-1(A)
	POPJ P,

MMWP1:	ADDM R,BA+1(A)
	ADD W,BAV+1(A)
	DPB B,[BDAEPR+1(A)]
	CLEARM BPCHD+1(A)
	POPJ P,

RMWP1:	ADDM R,WA+1(A)
	ADD W,WAV+1(A)
	DPB B,[BDAEPR+1(A)]
	CLEARM BPCHD+1(A)
	POPJ P,


BPPSD:	LDB T1,[BFILE,,BPREL(A)]
	AOS BPNFLS(T1)
	LDB C,[BRANK,,BPREL(A)]
	CAMLE C,BDPRK(T1)
	MOVEM C,BDPRK(T1)
IRP X,,[,+1,-1]	;IS IT PASSED?
	SKIPE C,@PPT-NPCS!X(B)
	CAILE C,1-BW(A)
	JRST .+5
	LDB D,[BFILE,,BPREL(C)]
	SUB D,T1
	MOVMS D
	SOJLE D,NOTPPB
	TERMIN
	LDB C,[BRANK,,BPREL(A)]
	MOVEI D,-BW(A)
	SETZM MMPWNF
MMBPPL:	CAIG C,2
	JRST MMPPB
	SKIPG T2,BOARD(D)
	JRST MMBPL2
	SKIPGE LMGSTD-PIECE(T2)
	JRST NOTPPB
	SKIPGE SNFBP-PIECE(T2)
	SETOM MMPWNF
MMBPL2:	IRP X,,[+1,-1]
	SKIPLE T2,BOARD!X(D)
	SKIPL LMGSTD-PIECE(T2)
	JRST .+2
	JRST NOTPPB
	TERMIN
	SUBI D,BW
	SOJA C,MMBPPL

MMPPB:	LDB T2,[BRANK,,BPREL(A)]
	MOVE T2,REVERS(T2)
	CAMLE T2,BPPRK(T1)
	MOVEM T2,BPPRK(T1)
	AOS NBPPP
	SKIPE MMPWNF
	TLO T2,400000
	MOVEM T2,PPASED(B)
	JRST .+2
NOTPPB:	AOS BNPNFL(T1)
	SKIPLE T1,BOARD+BW+1(A)	;SEE IF DEFENDED BY PAWN
	SKIPL SNFBP-PIECE(T1)
	JRST .+2
	JRST MMBPDP
	SKIPLE T1,BOARD+BW-1(A)
	SKIPL SNFBP-PIECE(T1)
	JRST .+2
MMBPDP:	SETOM PPTP(B)
	POPJ P,

MMBPWN:	PUSHJ P,BPPSD
PTPBP:
RMBP:	PUSH P,A
BPAS1:	ADDM J,BPAS-BW-1(A)
	ADDM J,BPAS-BW+1(A)
	SUBI A,BW
	SKIPL BOARD-BW(A)
	JRST BPAS1
	POP P,A
	ASH J,3
	ADDM J,BPAS-2*BW-1(A)
	ADDM J,BPAS-2*BW+1(A)
	LDB T1,[BRANK,,BPREL(A)]
	CAIE T1,7
	JRST BPAS2
	ADDM J,BPAS-3*BW-1(A)
	ADDM J,BPAS-3*BW+1(A)
BPAS2:	ASH J,3
	ADDM J,BPAS-BW-1(A)
	ADDM J,BPAS-BW+1(A)
	ADDM R,BA-BW+1(A)	;SET UP ATTACKS
	ADD W,BAV-BW+1(A)
	DPB B,[BDAUR-BW+1(A)]
	CLEARM BPCHD-BW+1(A)
	ADDM R,BA-BW-1(A)
	ADD W,BAV-BW-1(A)
	DPB B,[BDAUL-BW-1(A)]
	CLEARM BPCHD-BW-1(A)
	SKIPG GHSD
	POPJ P,	;NOT WHITE GHOST
	MOVEI T1,-BW+1(A)
	CAMN T1,GHLOC
	JRST MMWP1
	MOVEI T1,-BW-1(A)
	CAME T1,GHLOC
	POPJ P,
	ADDM R,BA-1(A)
	ADD W,BAV-1(A)
	DPB B,[BDAEPL-1(A)]
	CLEARM BPCHD-1(A)
	POPJ P,

MMRK:	MOVSI C,-4
MMRK1:	LDB T2,[PTIDS,,PIECE(B)]
	MOVE A,PIECEL(B)
MMRK3:	ADD A,RDT(C)
	SKIPGE D,BOARD(A)
	JRST MMRK2
	ATA
	DPB B,RDAT(C)
	JUMPE D,MMRK3
	MOVE T1,A
	DPB T2,BDBSQ(C)
	XCT OURGY(I)
	JRST MMRK7
	SKIPGE RFPCS-PIECE(D)
	JRST MMRK6	;RUNNING INTO OUR OWN ROOK OR QUEEN
MMRK4:	ADD A,RDT(C)
	SKIPGE D,BOARD(A)
	JRST MMRK2
	DPB T1,ONEBSQ(C)
	JUMPE D,MMRK4
MMRK2:	AOBJN C,MMRK1
	POPJ P,

MMRK6:	ADD A,RDT(C)
	SKIPGE D,BOARD(A)
	JRST MMRK2
	ATA
	DPB T1,ONEBSQ(C)
	JUMPE D,MMRK6
	XCT OURGY(I)
	JRST MMRK2
	SKIPL RFPCS-PIECE(D)
	JRST MMRK2
MMRK6B:	ADD A,RDT(C)
	SKIPGE D,BOARD(A)
	JRST MMRK2
	ATA
	JUMPE D,MMRK6B
	XCT OURGY(I)
	JRST MMRK2
	SKIPL RFPCS-PIECE(D)
	JRST MMRK2
	JRST MMRK6B

MMRK7:	ADD A,RDT(C)	;CHECK FOR POSSIBLE PINS
	SKIPGE D,BOARD(A)
	JRST MMRK2
	DPB T1,ONEBSQ(C)
	JUMPE D,MMRK7
	XCT OURGY+1(I)
	JRST MMRK2
	PUSH T,A	;RECORD POSSIBLE PIN
	HRLM C,(T)
	DPB B,[PINATP,,(T)]
	DPB T1,[PINOPS,,(T)]
	JRST MMRK2


RMWR:
RMBR:	MOVSI C,-4	;Q=0 REMOVE PIECE 1 REINSERT PIECE
RMBR1:	LDB T2,[PTIDS,,PIECE(B)]
	MOVE A,PIECEL(S)
RMBR3:	ADD A,RDT(C)
	SKIPGE D,BOARD(A)
	JRST RMBR2
	ATA
	DPB B,RDAT(C)
	JUMPE D,RMBR3
RMRE2:	MOVE T1,A
	XCT RMBRT2(Q)	;HACK BDBLK
	XCT OURGY(I)
	JRST RMBR7
	SKIPGE RFPCS-PIECE(D)
	JRST RMBR6
RMBR4:	ADD A,RDT(C)
	SKIPGE D,BOARD(A)
	JRST RMBR2
	XCT RMBRT3(Q)
	JUMPE D,RMBR4
RMBR2:	AOBJN C,RMBR1
	POPJ P,


RMRE:	MOVEI T2,0	;EXTEND ON RANK OR FILE
RMRE1:	ADD A,RDT(C)
	SKIPGE D,BOARD(A)
	POPJ P,	;C KNOWN TO BE -1,,N
	ATA
	DPB B,RDAT(C)
	DPB T2,ONEBSQ(C)
	JUMPE D,RMRE1
	LDB T2,[PTIDS,,PIECE(B)]
	JRST RMRE2

RMBR6:	ADD A,RDT(C)
	SKIPGE D,BOARD(A)
	JRST RMBR2
	ATA
	XCT RMBRT3(Q)
	JUMPE D,RMBR6
	XCT OURGY(I)
	JRST RMBR2
	SKIPL RFPCS-PIECE(D)
	JRST RMBR2
RMBR6B:	ADD A,RDT(C)
	SKIPGE D,BOARD(A)
	JRST RMBR2
	ATA
	JUMPE D,RMBR6B
	XCT OURGY(I)
	JRST RMBR2
	SKIPL RFPCS-PIECE(D)
	JRST RMBR2
	JRST RMBR6B

RMBRT3:	DPB B,ONEBSQ(C)
	DPB T1,ONEBSQ(C)

RMBRT2:	DPB B,BDBSQ(C)
	DPB T2,BDBSQ(C)

RMBR7:	ADD A,RDT(C)
	SKIPGE D,BOARD(A)
	JRST RMBR2
	XCT RMBRT3(Q)
	JUMPE D,RMBR7
	JRST RMBR2


MMQN:	PUSHJ P,MMRK
MMBS:	MOVSI C,-4
MMBS1:	LDB T2,[PTIDS,,PIECE(B)]
	MOVE A,PIECEL(B)
MMBS3:	ADD A,BDT(C)
	SKIPGE D,BOARD(A)
	JRST MMBS2
	ATA
	DPB B,BDAT(C)
	JUMPE D,MMBS3
	MOVE T1,A
	DPB T2,BDBD(C)
	XCT OURGY(I)
	JRST MMBS7
	SKIPGE LMGT-PIECE(D)	;OUR GUY
	JRST MMBS5
	SKIPGE DDPCS-PIECE(D)
	JRST MMBS6
MMBS4A:	ADD A,BDT(C)
MMBS4B:	SKIPGE D,BOARD(A)
	JRST MMBS2
	DPB T1,ONEBBD(C)
	JUMPE D,MMBS4A
MMBS2:	AOBJN C,MMBS1
	POPJ P,

MMBS6:	ADD A,BDT(C)
	SKIPGE D,BOARD(A)
	JRST MMBS2
	ATA
	DPB T1,ONEBBD(C)
	JUMPE D,MMBS6
	XCT OURGY(I)
	JRST MMBS2
	SKIPGE LMGT-PIECE(D)
	JRST MMBS5A
	SKIPL DDPCS-PIECE(D)
	JRST MMBS2
MMBS6A:	ADD A,BDT(C)
	SKIPGE D,BOARD(A)
	JRST MMBS2
	ATA
	JUMPE D,MMBS6A
	XCT OURGY(I)
	JRST MMBS2
	SKIPGE LMGT-PIECE(D)
	JRST MMBS5A
	SKIPL DDPCS-PIECE(D)
	JRST MMBS2
	JRST MMBS6A

MMBS5A:	HRRZ ZR,C
	XCT MMBST1(I)
	JRST MMBS2
	ADD A,BDT(C)
	ATA
	JRST MMBS2


MMBS5:	HRRZ ZR,C
	XCT MMBST1(I)
	JRST MMBS4A
	ADD A,BDT(C)
	ATA
	JRST MMBS4B

MMBST1:	CAIL ZR,2
	CAIGE ZR,2

MMBST:	CAIL T2,2
	CAIGE T2,2

MMBS7:
MMBS7A:	ADD A,BDT(C)
	SKIPGE D,BOARD(A)
	JRST MMBS2
	DPB T1,ONEBBD(C)
	JUMPE D,MMBS7A
	XCT OURGY+1(I)
	JRST MMBS2
	PUSH T,A	;PIN BASE SQUARE TO RH
	MOVEI ZR,4(C)
	HRLM ZR,(T)	;PIN DIRECTION TO LH
	DPB B,[PINATP,,(T)]
	DPB T1,[PINOPS,,(T)]
	JRST MMBS2


RMWQ:
RMBQ:	PUSHJ P,RMWR
RMWB:
RMBB:	MOVSI C,-4
	LDB T2,[PTIDS,,PIECE(B)]
RMBB1:	MOVE A,PIECEL(S)
RMBB3:	ADD A,BDT(C)
	SKIPGE D,BOARD(A)
	JRST RMBB2
	ATA
	DPB B,BDAT(C)
	JUMPE D,RMBB3
RMDE2:	MOVE T1,A
	XCT RMDT2(Q)
	XCT OURGY(I)
	JRST RMBB7	;HIS GUY
	SKIPGE LMGT-PIECE(D)
	JRST RMBB5
	SKIPGE DDPCS-PIECE(D)
	JRST RMBB6
RMBB4A:	ADD A,BDT(C)
RMBB4B:	SKIPGE D,BOARD(A)
	JRST RMBB2
	XCT RMDT3(Q)
	JUMPE D,RMBB4A
RMBB2:	AOBJN C,RMBB1
	POPJ P,


RMDE:	MOVEI T2,0
RMDE1:	ADD A,BDT(C)
	SKIPGE D,BOARD(A)
	POPJ P,
	ATA
	DPB B,BDAT(C)
	DPB T2,ONEBBD(C)
	JUMPE D,RMDE1
	LDB T2,[PTIDS,,PIECE(B)]
	JRST RMDE2

RMBB6:	ADD A,BDT(C)
	SKIPGE D,BOARD(A)
	JRST RMBB2
	ATA
	XCT RMDT3(Q)
	JUMPE D,RMBB6
	XCT OURGY(I)
	JRST RMBB2
	SKIPGE LMGT-PIECE(D)
	JRST RMBB5A
	SKIPL DDPCS-PIECE(D)
	JRST RMBB2
RMBB6A:	ADD A,BDT(C)
	SKIPGE D,BOARD(A)
	JRST RMBB2
	ATA
	JUMPE D,RMBB6A
	XCT OURGY(I)
	JRST RMBB2
	SKIPGE LMGT-PIECE(D)
	JRST RMBB5A
	SKIPL DDPCS-PIECE(D)
	JRST RMBB2
	JRST RMBB6A


RMBB5A:	HRRZ ZR,C
	XCT MMBST1(I)
	JRST RMBB2
	ADD A,BDT(C)
	ATA
	JRST RMBB2

RMBB5:	HRRZ ZR,C
	XCT MMBST1(I)
	JRST RMBB4A
	ADD A,BDT(C)
	ATA
	JRST RMBB4B

RMDT3:	DPB B,ONEBBD(C)
	DPB T1,ONEBBD(C)

RMDT2:	DPB B,BDBD(C)
	DPB T2,BDBD(C)


RMBB7:	ADD A,BDT(C)	;REMOVE ONEB
	SKIPGE D,BOARD(A)
	JRST RMBB2
	XCT RMDT3(Q)
	JUMPE D,RMBB7
	JRST RMBB2


IRPS BA,,BA WA,TAG,,RMBN RMWN,BAV,,BAV WAV,BPAS,,BPAS WPAS
TAG:	ADDM R,BA+2*BW+1(A)
	ADD W,BAV+2*BW+1(A)
	CLEARM BPCHD+2*BW+1(A)
	DPB B,[BDALR2+2*BW+1(A)]
	ADDM J,BPAS+2*BW+1(A)
	ADDM R,BA+2*BW-1(A)
	ADD W,BAV+2*BW-1(A)
	CLEARM BPCHD+2*BW-1(A)
	DPB B,[BDALL2+2*BW-1(A)]
	ADDM J,BPAS+2*BW-1(A)
	ADDM R,BA+-2*BW+1(A)
	ADD W,BAV+-2*BW+1(A)
	CLEARM BPCHD+-2*BW+1(A)
	DPB B,[BDAUR2-2*BW+1(A)]
	ADDM J,BPAS-2*BW+1(A)
	ADDM R,BA-2*BW-1(A)
	ADD W,BAV-2*BW-1(A)
	CLEARM BPCHD-2*BW-1(A)
	DPB B,[BDAUL2-2*BW-1(A)]
	ADDM J,BPAS-2*BW-1(A)
	ADDM R,BA+BW+2(A)
	ADD W,BAV+BW+2(A)
	CLEARM BPCHD+BW+2(A)
	DPB B,[BDALR1+BW+2(A)]
	ADDM J,BPAS+BW+2(A)
	ADDM R,BA+BW-2(A)
	ADD W,BAV+BW-2(A)
	CLEARM BPCHD+BW-2(A)
	DPB B,[BDALL1+BW-2(A)]
	ADDM J,BPAS+BW-2(A)
	ADDM R,BA-BW+2(A)
	ADD W,BAV-BW+2(A)
	CLEARM BPCHD-BW+2(A)
	DPB B,[BDAUR1-BW+2(A)]
	ADDM J,BPAS-BW+2(A)
	ADDM R,BA-BW-2(A)
	ADD W,BAV-BW-2(A)
	CLEARM BPCHD-BW-2(A)
	DPB B,[BDAUL1-BW-2(A)]
	ADDM J,BPAS-BW-2(A)
	POPJ P,

TERMIN
IRPS BA,,BA WA,TAG,,RMBK RMWK,BAV,,BAV WAV,BPAS,,BPAS WPAS
TAG:	ADDM R,BA+BW(A)
	ADD W,BAV+BW(A)
	CLEARM BPCHD+BW(A)
	DPB B,[BDAFB+BW(A)]
	ADDM J,BPAS+BW(A)
	ADDM R,BA-BW(A)
	ADD W,BAV-BW(A)
	CLEARM BPCHD-BW(A)
	DPB B,[BDAFT-BW(A)]
	ADDM J,BPAS-BW(A)
	ADDM R,BA+1(A)
	ADD W,BAV+1(A)
	CLEARM BPCHD+1(A)
	DPB B,[BDARR+1(A)]
	ADDM J,BPAS+1(A)
	ADDM R,BA-1(A)
	ADD W,BAV-1(A)
	CLEARM BPCHD-1(A)
	DPB B,[BDARL-1(A)]
	ADDM J,BPAS-1(A)
	ADDM R,BA+BW+1(A)
	ADD W,BAV+BW+1(A)
	CLEARM BPCHD+BW+1(A)
	DPB B,[BDALR+BW+1(A)]
	ADDM J,BPAS+BW+1(A)
	ADDM R,BA+BW-1(A)
	ADD W,BAV+BW-1(A)
	CLEARM BPCHD+BW-1(A)
	DPB B,[BDALL+BW-1(A)]
	ADDM J,BPAS+BW-1(A)
	ADDM R,BA-BW+1(A)
	ADD W,BAV-BW+1(A)
	CLEARM BPCHD-BW+1(A)
	DPB B,[BDAUR-BW+1(A)]
	ADDM J,BPAS-BW+1(A)
	ADDM R,BA-BW-1(A)
	ADD W,BAV-BW-1(A)
	CLEARM BPCHD-BW-1(A)
	DPB B,[BDAUL-BW-1(A)]
	ADDM J,BPAS-BW-1(A)
	POPJ P,

TERMIN



RMPC:	LDB I,[430100,,PIECE(S)]	;T  SET UP  TO RECORD POSSIBLE NEW PINS
	MOVE A,PIECEL(S)	;REMOVE PIECE IN S
IFN HSCOD,[		;UPDATE HSKEY
	LDB Q,[PTID,,PIECE(S)]
	SKIPE I
	ADDI Q,10
	MOVE B,RANDN(A)
	ROT B,1(Q)
	XORM B,HSKEY
]	LDB Q,[BFILE,,BPREL(A)]
	SKIPL LMGT(S)
	JRST RMPCD
	SKIPE PPASED(S)
	SOS NWPPP(I)
	CLEARM PPASED(S)
	SETOM MMPIVF	;PAWNS INVOLVED
	SETOM MMFL-1(Q)
	SETOM MMFL(Q)
	SETOM MMFL+1(Q)
RMPCD:	LDB B,[BRANK,,BPREL(A)]
	XCT RMPPT4(I)
	PUSHJ P,PTPCD	;POSSIBLY ALTERING PAWN STRUCTURE BY STOPPING DOUBLE ADV
	XCT RMPPT1(I)
	JRST RMPCB
	XCT RMPPT2(I)	;PICK UP CONTENTS OF RANK 2 SQUARE
	XCT RMPPT3(I)	;SKIP ON HIS PAWN
	JRST RMPCB
	MOVE D,PPTP-PIECE(T1)
	CAIN T1,2
	JRST RMPCB
	SETOM MMPIVF
	SETOM MMFL(Q)	;MAYBE THIS P ISNT BACKWARD ANY MORE
	SETOM MMFL+1(Q)
	SETOM MMFL-1(Q)	;PAWNS MAY BE MADE FORWARD
RMPCB:	XCT RMPPT2(I)
	XCT RMPPT3(I)	;CHECK IF UNBLOCKING P WHICH CAN DEFEND FORWARD P
	JRST RMPCE
	SKIPLE T1,@RMPTA(I)
	XCT RMPPT3(I)
	JRST RMPCE1
	SKIPN PPTP-PIECE(T1)
	JRST RMPCE1
	SETOM MMPIVF
	SETOM MMFL+1(Q)
RMPCE1:	SKIPLE T1,@RMPTB(I)
	XCT RMPPT3(I)
	JRST RMPCE
	SKIPN PPTP-PIECE(T1)
	JRST RMPCE
	SETOM MMPIVF
	SETOM MMFL-1(Q)
RMPCE:	MOVN R,PCATV(S)
	MOVN J,PASIN(S)
	CLEARB B,Q
	PUSHJ P,@RMDTB(S)	;REMOVE BDA WA BA ONEB DUE TO THIS PIECE
	MOVE A,PIECEL(S)
	SKIPN T2,BDBLK(A)
	JRST RMPC1	;NO COMPLICATION DUE TO UNBLOCKING SOMETHING
	MOVEI C,0
RMPC3:	MOVEI T1,0
	LSHC T1,4
	JUMPE T1,RMPC4
	MOVE B,BDAST(T1)
	PUSH P,S
	PUSH P,T2
	PUSH P,C
	LDB I,[430100,,PIECE(B)]
	MOVN R,PCATV(B)
	MOVN J,PASIN(B)
	MOVE A,PIECEL(B)	;COMPUTE TOTAL PCATV OF WHATS BEING UNBLOCKED

RMPC3B:	LDB Q,RDAT(C)
	JUMPE Q,RMPC3A
	SKIPGE SLDPC(Q)
	XCT RMOY2(I)
	JRST RMPC3A
	SUB R,PCATV(Q)
	SUB J,PASIN(Q)
	MOVE A,PIECEL(Q)
	JRST RMPC3B
RMPC3A:	MOVEI W,0
	SKIPGE SLDPC(S)
	JRST RMPC5	;WA BA ENTRIES POSSIBLY ALREADY MADE
	SKIPGE LMGT(S)
	JRST RMPC6	;WA BA ENTRY POSSIBLY MADE FOR SQUARE IMMEDIATELY BEYOND PAWN
RMPC6R:	MOVE A,PIECEL(S)
	MOVE T1,C
	HRROS C
	TRZ C,4	;COMPENSATE IF DIAG
	LSH T1,-2
	MOVNS R
	MOVNS J
	MOVEI Q,1
	PUSHJ P,@RMLCT(T1)	;EXTEND PIECE IN B ALONG LINE IN C STARTING FROM SQ IN A
	ADDM W,PDV(B)
	MOVE A,PIECEL(B)
	POP P,C
RMPC4A:	LDB Q,RDAT(C)
	JUMPE Q,RMPC4B
	SKIPGE SLDPC(Q)
	XCT RMOY2(I)
	JRST RMPC4B
	ADDM W,PDV(Q)
	MOVE A,PIECEL(Q)
	JRST RMPC4A
RMPC4B:	POP P,T2
	POP P,S
RMPC4:	JUMPE T2,RMPC1A
RMPC2:	AOJA C,RMPC3


RMPO2:	TDZA C,C
RMPO2A:	MOVEI C,4
	HRLI C,-4
RMPO2C:	LDB T1,ONEBSQ(C)
	JUMPN T1,RMPO3
RMPO2B:	AOBJN C,RMPO2C
	POPJ P,


RMPO3:
RMPO3A:	ADD A,RDT(C)
	SKIPGE D,BOARD(A)
	JRST RMPO3R
	DPB T1,ONEBSQ(C)
	JUMPE D,RMPO3A
RMPO3R:	MOVE A,PIECEL(S)
	JRST RMPO2B

RMLCT:	RMRE	;EXTEND ON RANK OR FILE
	RMDE	;EXTEND ON DIAG

RMPC1A:	MOVE A,PIECEL(S)
	CLEARM BDBLK(A)
RMPC1:	SKIPE ONEB1(A)
	PUSHJ P,RMPO2
	SKIPE ONEB2(A)
	PUSHJ P,RMPO2A
	POPJ P,

RMPC6:	CAIL C,4	;NOT DIA
	XCT RMDTT(I)	;SKIP ON DIAG TOWARD OPPOSITION
	JRST RMPC6R
	XCT RMOY3(I)
	JRST RMPC6R	;NOT OUR SIDE
	MOVE A,PIECEL(S)
	ADD A,RDT(C)
	ATAS
	JRST RMPC6R


RMPC5:	SKIPGE @RMP5T(C)
	XCT RMOY3(I)
	JRST RMPC6R	;NOT SLIDING ALONG THIS LINE
	MOVE A,PIECEL(S)
RMPC5A:	ADD A,RDT(C)
	SKIPGE D,BOARD(A)
	JRST RMPC6R
	ATAS
	JUMPE D,RMPC5A
	XCT OURGY(I)
	JRST RMPC6R
	SKIPGE @RMP5T1(C)
	JRST RMPC5A	;OUR PIECE ALSO SLIDING ALONG THIS LINE
	CAIGE C,4
	JRST RMPC6R
	SKIPGE LMGT-PIECE(D)
	XCT RMDTT(I)
	JRST RMPC6R
	ADD A,RDT(C)
	ATAS
	JRST RMPC6R


PTPC:	MOVE A,PIECEL(S)	;PUT ON PIECE IN S
	LDB I,[430100,,PIECE(S)]
IFN HSCOD,[		;UPDATE HSKEY
	LDB Q,[PTID,,PIECE(S)]
	SKIPE I
	ADDI Q,10
	MOVE B,RANDN(A)
	ROT B,1(Q)
	XORM B,HSKEY
]	LDB Q,[BFILE,,BPREL(A)]
	SKIPL LMGT(S)
	JRST PTPCB
	SETOM MMFL-1(Q)
	SETOM MMFL(Q)
	SETOM MMFL+1(Q)
	SETOM MMPIVF
PTPCB:	LDB B,[BRANK,,BPREL(A)]
	XCT RMPPT4(I)
	PUSHJ P,PTPCD
;	XCT RMPPT1(I)
;	JRST PTPCA
	XCT RMPPT2(I)
	XCT RMPPT3(I)
	JRST PTPCA
	SETOM MMPIVF
	SETOM MMFL(Q)	;MAYBE P IS BACKWARD NOW
	SETOM MMFL+1(Q)	;OTHER PAWNS MAY BECOME FORWARD
	SETOM MMFL-1(Q)
PTPCA:	SKIPE T1,ONEB1(A)
	PUSHJ P,PTPO2
	SKIPE T2,ONEB2(A)
	PUSHJ P,PTPO2A
	SKIPE T1,BDA1(A)
	PUSHJ P,PTPC1
	MOVE A,PIECEL(S)
	SKIPE T1,BDA2(A)
	PUSHJ P,PTPC1A
	MOVE R,PCATV(S)
	MOVE J,PASIN(S)
	MOVEI Q,1
	MOVE B,S
	LDB I,[430100,,PIECE(S)]
	MOVE A,PIECEL(S)
	MOVEI W,0
	PUSHJ P,@PTPTB(S)
	MOVEM W,PDV(B)
	POPJ P,

PTPC1A:	SKIPA T2,[-2,,6]	;COUNT AND INITIAL DIRECTION
PTPC1:	MOVSI T2,-6
	MOVE C,[440600,,T1]
PTPC1C:	ILDB Q,C
	JUMPN Q,PTPC1B
PTPC1D:	AOBJN T2,PTPC1C
	POPJ P,


PTPC1B:	SKIPL SLDPC(Q)
	JRST PTPC1D
	LDB I,[430100,,PIECE(Q)]

PTP2:	MOVN R,PCATV(Q)
	MOVN J,PASIN(Q)
	MOVE A,PIECEL(Q)	;COMPUTE TOTAL PCATV OF WHATS BEING CUT OFF
	MOVEM Q,PTP2T1
PTP2E:	LDB Q,RDAT(T2)
	JUMPE Q,PTP2D
	SKIPGE SLDPC(Q)
	XCT RMOY2(I)
	JRST PTP2D
	SUB R,PCATV(Q)
	SUB J,PASIN(Q)
	MOVE A,PIECEL(Q)
	JRST PTP2E
PTP2D:	CLEARB Q,TT	;DECIDE WHETHER TO LEAVE WA-BA ALONE Q=0
	SKIPGE @RMP5T(T2)	;OR SUB OUT Q=1 SKIP ON PIECE NOT SLIDING IN THAT DIRECTION
	XCT RMOY1(I)
	MOVEI Q,1
	MOVE A,PIECEL(S)
	MOVE B,PTP2T1
	LDB D,[PTIDS,,PIECE(B)]
	MOVE B,A	;SAVE SQUARE BLOCKED AT
	DPB D,BDBSQ(T2)	;NOW BLOCKED HERE
	MOVEI W,0
PTP2A:	ADD A,RDT(T2)
	SKIPGE D,BOARD(A)
	JRST PTP3
	XCT PTP2T(Q)
	XCT ATS(I)
	XCT PASI(I)
PTP2A1:	CLEARM BPCHD(A)
	DPB TT,RDAT(T2)
	DPB B,ONEBSQ(T2)	;NOW THRU ONE BLOCKER
	JUMPE D,PTP2A
	DPB TT,BDBSQ(T2)	;NO LONGER BLOCKED HERE
	JUMPE Q,PTPO1
PTP2C:	XCT OURGY(I)
	JRST PTPO1	;WA BA OK BUT REMOVE OLD ONEB
	SKIPGE LMGT-PIECE(D)
	JRST PTP2C1
	SKIPL @RMP5T1(T2)	;SLIDING PIECE IN RIGHT DIRECTION?
	JRST PTPO1
PTP3B:	ADD A,RDT(T2)	;REMOVE OLD ONEB + ALSO SUB OUT
	SKIPGE D,BOARD(A)
	JRST PTP3
	ATAS
	DPB TT,ONEBSQ(T2)	;NOW 2 AWAY SO CLEAR OUT
	JUMPE D,PTP3B
PTPC3D:	XCT OURGY(I)	;JUST SUB OUT
	JRST PTP3
	SKIPGE LMGT-PIECE(D)
	JRST PTP2C2
	SKIPL @RMP5T1(T2)
	JRST PTP3
PTPC3C:	ADD A,RDT(T2)
	SKIPGE D,BOARD(A)
	JRST PTP3
	ATAS
	JUMPE D,PTPC3C
	JRST PTPC3D

PTP2C2:	HRRZ D,T2
	TRNE T2,4
	XCT RMDTT1(I)
	JRST PTP3
	ADD A,RDT(T2)
	ATAS
	SUB A,RDT(T2)
PTP3:	SKIPGE LMGT(S)
	TRNN T2,4	;SKIP ON DIAGS
	JRST PTPVL
	HRRZ D,T2	;PIECE MUST BE DDPCS BECAUSE OF DIRECTION
	XCT RMOY3+1(I)
	XCT RMDTT1(I)
	JRST PTPVL
	MOVE A,PIECEL(S)
	ADD A,RDT(T2)
	MOVNS R
	MOVNS J
	ATA	;STILL ATTACKING HERE THRU PAWN
	MOVNS J
	MOVNS R
PTPVL:	MOVE Q,PTP2T1
	ADDM W,PDV(Q)
	MOVE A,PIECEL(Q)
PTPVL1:	LDB Q,RDAT(T2)
	JUMPE Q,PTPC1D
	SKIPGE SLDPC(Q)
	XCT RMOY2(I)
	JRST PTPC1D
	ADDM W,PDV(Q)
	MOVE A,PIECEL(Q)
	JRST PTPVL1


PTP2T:	JRST PTP2A1
	XCT RMINS(I)


PTP2C1:	HRRZ D,T2
	TRNE T2,4
	XCT RMDTT1(I)
	JRST PTPO1
	ADD A,RDT(T2)
	ATAS
	JRST PTPO1A

PTP2T1:	0	;TEMP

PTPO1:	ADD A,RDT(T2)	;JUST CLEAR ONEB
PTPO1A:	SKIPGE D,BOARD(A)
	JRST PTP3
	DPB TT,ONEBSQ(T2)
	JUMPE D,PTPO1
	JRST PTP3

PTPO2:	TDZA T2,T2
PTPO2A:	MOVEI T2,4
	HRLI T2,-4
	MOVEI B,0
PTPO2B:	LDB C,ONEBSQ(T2)
	JUMPN C,PTPO2C
PTPO2D:	AOBJN T2,PTPO2B
	POPJ P,

PTPO2C:	ADD A,RDT(T2)
	SKIPGE D,BOARD(A)
	JRST PTPO2R
	DPB B,ONEBSQ(T2)
	JUMPE D,PTPO2C
PTPO2R:	MOVE A,PIECEL(S)
	JRST PTPO2D


PTPCD:	XCT RMPPT5(I)
	XCT RMPPT3(I)
	POPJ P,	;RANK 2 NOT OCC OR NOT HIS P
	LDB T2,[BFILE,,BPREL(A)]
	SKIPE T1,@RMPPT7(I)
	XCT RMPPT3(I)
	JRST PTPCD1
PTPCD2:	SETOM MMFL(T2)
	SETOM MMPIVF
PTPCD3:	SKIPE T1,@RMPTA(I)
	XCT RMPPT3(I)
	JRST PTPCD4
	SETOM MMPIVF
	SETOM MMFL+1(T2)
PTPCD4:	SKIPE T1,@RMPTB(I)
	XCT RMPPT3(I)
	POPJ P,
	SETOM MMPIVF
	SETOM MMFL-1(T2)
	POPJ P,

PTPCD1:	SKIPE T1,@RMPPT8(I)
	XCT RMPPT3(I)
	JRST PTPCD3
	JRST PTPCD2
CATC:	AOJE B,CATSC1
	SOSL CATSCC
	POPJ P,
CATSC1:	MMSAVAC
	CLEARM ICERRF
	PUSHJ P,CORCMP
	PUSHJ P,ICSTO
	PUSHJ P,ATEV
	PUSHJ P,.CAT1
	PUSHJ P,CORCMP
	MOVEI B,TYO
	PUSHJ P,ICCMP
	SKIPGE ICERRF
	JRST CATC1
CATC2:	MMRSAC
	POPJ P,

CATC1:	PUSHJ P,DISUP
	PUSHJ P,TYI
	JRST CATC2

CATCSA:	BLOCK 17

CORCMP:	MOVSI W,-8	;COMPUTE WPAS, BPAS FOR ALL SQS
	MOVE A,[-8,,2*BW+1]
	MOVEI I,0
CORC1:	SKIPL BPCHD(A)
	PUSHJ P,MCAF
	AOBJN A,CORC1
	ADD A,[-8,,2]
	AOBJN W,CORC1
	POPJ P,

MMIC1:	MMSAVAC
	LDB S,[MPC,,LMV]
	PUSHJ P,RMPC	;REMOVE PIECE MOVING
MMICR:	MMRSAC
	POPJ P,


MMIC3:	MMSAVAC
	MOVE A,PIECEL(B)
	PUSH P,BOARD(A)
	CLEARM BOARD(A)
	PUSH P,A	;AVOID POSSIBLE INTERFERENCE FROM PIECE MAKING CAPTURE
	LDB S,[MPTK,,LMV]
	PUSHJ P,RMPC
MMICR1:	POP P,A
	POP P,BOARD(A)
	JRST MMICR

MMIC7:	MMSAVAC
	LDB S,[MPC,,LMV]
	PUSHJ P,PTPC
	JRST MMICR

MMIC2:	MMSAVAC
	CLEARM BPINT+1	;RECALCULATE PINS
	MOVE A,[BPINT+1,,BPINT+1+1]
	BLT A,PINT+NPC+1-1
	MOVEI A,PINDT-1
	MOVEM A,PINFS
	
	MOVE T,[-LPINTB,,PINTB]
	MOVE B,[-NPC,,1]
MMP1:	SKIPN A,PIECEL(B)
	JRST MMP2
	SKIPE ONEB1(A)	;SEE IF THIS PIECE IS BASE OF PIN
	PUSHJ P,MMP3
	SKIPE ONEB2(A)
	PUSHJ P,MMP3A
MMP2:	AOBJN B,MMP1
MMP2B:	CAMN T,[-LPINTB,,PINTB]
	JRST MMP2A
	PUSHJ P,MCAT4	;CHECK OUT POSSIBLE PINS
	JRST MMP2B

MMP2A:	SKIPL MMPIVF	;SKIP IF PAWNS INVOLVED
	JRST MMP4
	MOVSI B,-8
MMIC2H:	SKIPL MMFL+1(B)
	JRST MMIC2G
	CLEARM WPNFLS+1(B)
	CLEARM BPNFLS+1(B)
	CLEARM WNPNFL+1(B)
	CLEARM BNPNFL+1(B)
	CLEARM WPPRK+1(B)
	CLEARM BPPRK+1(B)
MMIC2G:	AOBJN B,MMIC2H

	PUSHJ P,MMICP
MMP4:	CLEARM WAAPP
	MOVE A,[WAAPP,,WAAPP+1]
	BLT A,BAAPP+9
	SKIPE NWPPP
	PUSHJ P,WPPAC
	SKIPE NBPPP
	PUSHJ P,BPPAC
	JRST MMICR


MMICP:	MOVE B,[-8,,1]
MMIC2D:	SKIPE A,PIECEL(B)
	SKIPL LMGT(B)
	JRST MMIC2C
	LDB C,[BFILE,,BPREL(A)]
	SKIPL MMFL(C)
	JRST MMIC2C	;THIS P NOT AFFECTED
	SKIPE PPASED(B)
	SOS NWPPP
	CLEARM PPASED(B)
	CLEARM PPTP(B)
	PUSHJ P,WPPSD
	HRLM B,(P)
	PUSH P,[MMICPW]
MMIC2C:	AOBJN B,MMIC2D

	MOVE B,[-8,,NPCS+1]
MMIC2E:	SKIPE A,PIECEL(B)
	SKIPL LMGT(B)
	JRST MMIC2F
	LDB C,[BFILE,,BPREL(A)]
	SKIPL MMFL(C)
	JRST MMIC2F
	SKIPE PPASED(B)
	SOS NBPPP
	CLEARM PPASED(B)
	CLEARM PPTP(B)
	PUSHJ P,BPPSD
	HRLM B,(P)
	PUSH P,[MMICPB]
MMIC2F:	AOBJN B,MMIC2E
	POPJ P,

MMICPW:	HLRZ B,(P)
	MOVE A,PIECEL(B)
	JRST WPBAK

MMICPB:	HLRZ B,(P)
	MOVE A,PIECEL(B)
	JRST BPBAK


MMP3:	SKIPA T2,[-4,,0]
MMP3A:	MOVE T2,[-4,,4]
MMP3D:	LDB C,ONEBSQ(T2)
	JUMPN C,MMP3B
MMP3C:	AOBJN T2,MMP3D
	POPJ P,



WPPAC:	MOVSI B,-8
WPPAC2:	SKIPN A,WPPRK+1(B)
	JRST WPPAC1
	IMULI A,BW
	ADDI A,2*BW+1(B)
WPPAC3:	SKIPGE C,BOARD+BW(A)
	JRST WPPAC1
	JUMPG C,WPPAC4
WPPAC5:	MOVE C,BA+BW(A)
	ADDM C,BAAPP+1(B)
	ADDI A,BW
	JRST WPPAC3

WPPAC4:	SKIPL (C)
	JRST WPPAC5
	SETOM BAAPP+1(B)	;W GUY PATH BLOCKED
WPPAC1:	AOBJN B,WPPAC2
	POPJ P,

BPPAC:	MOVSI B,-8
BPPAC2:	SKIPN A,BPPRK+1(B)
	JRST BPPAC1
	MOVE A,REVERS(A)
	IMULI A,BW
	ADDI A,2*BW+1(B)
BPPAC3:	SKIPGE C,BOARD-BW(A)
	JRST BPPAC1
	JUMPG C,BPPAC4
BPPAC5:	MOVE C,WA-BW(A)
	ADDM C,WAAPP+1(B)
	SUBI A,BW
	JRST BPPAC3

BPPAC4:	SKIPGE (C)
	JRST BPPAC5
	SETOM WAAPP+1(B)
BPPAC1:	AOBJN B,BPPAC2
	POPJ P,

MMP3B:	MOVE D,@BOARD(C)
	XOR D,PIECE(B)
	JUMPL D,MMP3C
	LDB Q,RDATS(T2)
	MOVE D,PIECE(Q)
	XOR D,PIECE(B)
	JUMPGE D,MMP3C
	PUSH T,A
	HRLM T2,(T)
	DPB Q,[PINATP,,(T)]
	DPB C,[PINOPS,,(T)]
	JRST MMP3C

MMIC5Q:	MOVEI S,WQR-PIECE(T)
	JRST MMIC5A

MMIC5:	MOVEI S,WKR-PIECE(T)
MMIC5A:	MMSAVAC
	PUSHJ P,RMPC
	MOVE A,PIECEL(S)
	PUSH P,BOARD(A)
	CLEARM BOARD(A)
	PUSH P,A	;AVOID POSSIBLE INTERFERENCE BY ROOK IN K REMOVAL
	MOVE I,CATCSA+I
	MOVE S,KINGT(I)
	PUSHJ P,RMPC
	JRST MMICR1

KINGT:	WKING-PIECE
	BKING-PIECE

MMIC6Q:	MOVEI S,WQR-PIECE(T)
	JRST MMIC6A


MMIC6:	MOVEI S,WKR-PIECE(T)
MMIC6A:	MMSAVAC
	MOVE A,@OKINGT(I)
	PUSH P,BOARD(A)
	CLEARM BOARD(A)
	PUSH P,A	;AVOID POSSIBLE INTERFERENCE BY K IN ROOK PLACEMENT
	PUSHJ P,PTPC
	POP P,A
	POP P,BOARD(A)
	MOVE I,CATCSA+I
	MOVE S,KINGT(I)
	PUSHJ P,PTPC
	JRST MMICR

MMIC8:	MMSAVAC
	LDB S,[MPTK,,LMV]
	PUSHJ P,PTPC
	JRST MMICR

MMIC5B:	CAIE T2,2
	JRST MMIC5
	JRST MMIC5Q

MMIC6B:	CAIE T2,2
	JRST MMIC6
	JRST MMIC6Q

;;TYI
GERR:	MOVE P,RMERR1
	PUSHJ P,QMTYO
	JRST CRR

GSYL:	CLEARB B,SQN
	CLEARM GSYLNF
	SKIPE ALGSW1
	JRST ALG4
GSYL4:	PUSHJ P,RCHA
	MOVEM A,LCHAR
IFN UTAPE,[
	SETOM TERMF
	CAIN A,40
	CLEARM TERMF
]
	CAIN A,177
	JRST GERR
	CAIL A,"1
	CAILE A,"9
	JRST GSYL1
	JUMPE B,GSYLN
	SUBI A,"0-1
	HRROI C,-11.(A)
	SKIPE SIDE
	MOVN A,C
	IMULI A,BW
	MOVEM A,SQN
	TDNE B,[77,,777777]
	JRST GSYL5
	TLNE B,7700
	JRST ALG1	;LLN
ALG4A:	LDB W,[360600,,B]
	CAIN W,'B	;LN
	JRST ALG2
	CAIL W,'A
	CAILE W,'H
	JRST GSYL5
ALG3:	MOVE A,LCHAR
	SUBI A,"0-1
	IMULI A,BW
	ADD A,REVERS-'A+1(W)
	SETOM CALGNF
	MOVEM A,SQN
	POPJ P,
GSYL5:	MOVSI C,-NSYMS
	CAMN B,SYMT(C)
	JRST GSYL6
GSYL5B:	AOBJN C,.-2
	JRST GERR


ALG2:	SKIPL CALGNF
	SKIPE ALGSW
	JRST ALG3
	JRST GSYL5

ALG1:	LDB W,[300600,,B]
	CAIE W,'K
	CAIN W,'Q
	JRST ALG1A
	LDB W,[360600,,B]
	CAIL W,'A
	CAILE W,'H
	JRST GSYL5
ALG1B:	MOVEM B,ALGSW1
	LSH B,6
	TLZ B,7777
	CLEARM SQN
	SETOM CALGNF
	JRST GSYL5

ALG1A:	LDB W,[360600,,B]
	CAIL W,'A
	CAILE W,'H
	JRST GSYL5
	SKIPL CALGNF
	SKIPE ALGSW
	JRST ALG1B
	JRST GSYL5

ALG4:	MOVE B,ALGSW1
	TLZ B,7777
	CLEARM ALGSW1
	JRST ALG4A

GSYL1:	CAIN A,"X
	JRST GSYL1A
	CAIL A,"A
	CAILE A,"Z
	JRST GSYL3
	SUBI A,40
	LSHC A,-6
	JRST GSYL4
GSYL3:
IFN BOOK,[
	SKIPL BOOKF1
	JRST GSYL3A
	CAIN A,40
	MOVEI A,15	;SPACE = CR IF READING BOOK
GSYL3A:
]	CAIE A,"-
	CAIN A,40
	JRST GSYL5A
	CAIE A,"(
	CAIN A,")
	JRST GSYL5A
	CAIN A,"/
	JRST GSYL5A
	CAIE A,"=
	CAIN A,"?
	JRST GSYLEQ
	CAIE A,"*
	JRST GSYL7
GSYL1A:	SETOM TAKES
	SETOM TAKES1
	SKIPN B
	SETOM TAKES2

GSYL5A:	JUMPN B,GSYL5
	JRST GSYL4

GSYLEQ:	AOS EQSGNF
	JUMPN B,GSYL5
	POPJ P,

GSYL7:	CAIL A,11
	CAILE A,15
	JRST GERR
	SETOM GME
	JUMPE B,CPOPJ
	JRST GSYL5



GSYLN:	MOVEI C,-"0(A)
	SETOM GSYLNF
GSYLN1:	CLEARM GSYLMF
GSYLN3:	PUSHJ P,RCHA
	CAIN A,177
	JRST GERR
	CAIN A,"-
	JRST GSYLN5
	CAIL A,"0
	CAILE A,"9
	JRST GSYLN4
	IMULI C,10.
	ADDI C,-"0(A)
	JRST GSYLN3

GSYLN5:	SETOM GSYLMF
	JRST GSYLN3

GSYLN4:	CAIL A,11
	CAILE A,15
	SKIPA
	SETOM GME
	SKIPE GSYLMF
	MOVNS C
	POPJ P,


GSYL6A:	MOVE P,RMERR1	;PSEUDO DISPATCH OR PARAMETER HACKS
	MOVE B,LCHAR
	CAIL B,"0
	CAILE B,"9
	JRST GSYL6G
	JRST GERR

GSYL6G:IFN BOOK,[CAIL A,BKSMS-SYMT
	JRST GSYL6B
	SKIPE BOOKF1
	JRST GSYL5B	;DONT ALLOW NON BOOK OPS IN BOOK
]
	SKIPG B,SQTB(A)
	JRST GSYL6C
GSYL6E:	MOVEI B,0
	PUSHJ P,@SQTB(A)
	SKIPGE UREADF
	POPJ P,
GSYL6F:	PUSHJ P,LATYO
	JRST CRR

GSYL6C:	SKIPN EQSGNF
	JRST GSYL6D
	TLNN B,200000	;OUTPUT PARAMETER VALUE
	SKIPA A,-1(B)
	MOVE A,(B)
	MOVEI B,TYO
	PUSHJ P,DPT
	JRST GSYL6F

GSYL6D:	TLNN B,200000
	JRST GSYL6E
	PUSHJ P,GETNUM	;INPUT PARAMETER VALUE
	MOVEM C,(B)
	JRST GSYL6F


IFN BOOK,[
GSYL6B:	SKIPN BOOKF1
	JRST GERR	;NOT READING BOOK
	JRST @SQTB(A)
]


GSYL6:	HRRZ A,C
	CAIL A,SYMPS-SYMT
	JRST GSYL6A	;PSEUDO
	MOVE A,SQN
	HRLS A
	ADD A,SQTB(C)
	MOVE T1,SIDE
	SKIPGE TAKES2
	XORI T1,NPCS
	SKIPE T1
	ADDI C,PTBL	;BLACK PIECES
	SKIPN SQN
	MOVE A,PTB(C)
	TLNE A,377777
	JUMPL A,GERR
	TRNE A,400000
	JRST GSYP1	;PAWN HACK
GSYP3:	AOSN TAKES1
	SETOM TAKES2
	POPJ P,


GSYP1:	SKIPE SQN
	JRST GSYP3
	LDB T1,[400,,A]
	LDB T2,[40400,,A]
	MOVEI A,0
	MOVSI C,200000
	MOVE S,SIDE
	SKIPGE TAKES2
	XORI S,NPCS

GSYP2:	SKIPE Q,PIECEL+1(S)
	SKIPL LMGT+1(S)
	JRST GSYP4
	LDB Q,[BFILE,,BPREL(Q)]
	CAME Q,T1
	CAMN Q,T2
	IOR A,C
GSYP4:	LSH C,-1
	TLNN C,400
	AOJA S,GSYP2
	JRST GSYP3

RMNI:	LDB B,[014300,,PLYN]
	CAIN C,1(B)
	JRST RMOVE3
	PTTY [ASCII /MOVE NUMBER DIFFERS!/]
	JRST RMOVE3

RMOVE:	LDB A,[100,,PLYN]
	IMULI A,NPCS
	MOVEM A,SIDE	;0=>WHITE NPCS=>BLACK
	PUSHJ P,CAT
RMOVE0:	MOVEM P,RMERR1
	JRST RMOVE3

PROMPC:	0	;PIECE PAWN PROMOTED TO

PROTX1:	'Q
	'R
	'B
	'N

RMOVE5:	PUSHJ P,RCHA
	SUBI A,40
	JUMPE A,RMOVE5
	MOVSI B,-4
	CAME A,PROTX1(B)
	AOBJN B,.-1
	JUMPGE B,RMERR
	EXCH B,PROMPC
	JUMPE B,RMOVE6

RMERR0:	JUMPE D,CPOPJ
RMERR:	PUSHJ P,QMTYO
	PUSHJ P,TYO
	PUSHJ P,CRR

RMOVE3:	CLEARM CALGNF
	CLEARM ALGSW1
	CLEARB B,CASLF
	CLEARB D,TAKES
	CLEARB TT,GME
	CLEARM TAKES1
	CLEARM TAKES2
	CLEARM RNSQS
	CLEARM RNPCS
	SETZM PROMPC
RMOVE6:	CLEARM EQSGNF
RMOVE2:	SKIPE EQSGNF
	JRST RMOVE5
	PUSHJ P,GSYL
	SKIPE GSYLNF
	JRST RMNI
	JUMPE B,RMOVE1
	CAMN A,[1,,]
	SETOM CASLF
	CAILE D,4
	JRST RMERR
	SKIPN SQN
	AOSA T,RNPCS
	AOS I,RNSQS
	MOVEM A,SYLT(D)
	AOS D
	LSH TT,1
	SKIPN SQN
	TRO TT,1
	SKIPE SQN
	JRST RMOVE1
	SOJN T,RMOVE1
	SKIPE RNSQS	;SQ BEFORE FIRST PC DOESNT WORK--BUG
	JRST RMERR

RMOVE1:	SKIPL GME
	JRST RMOVE2
	CAIGE D,2
	JRST RMERR0
	SKIPE CASLF
	JRST RMOVE4

	ANDI TT,17
	SKIPGE PSTB(TT)
	JRST RMERR
	LDB A,[PMI,,PSTB(TT)]
	MOVE T,SYLT-2(A)	;POSS PIECE TO MOVE
	LDB A,[SMI,,PSTB(TT)]
	MOVE I,SYLT-2(A)	;POSS ORG SQUARE
	LDB A,[DPMI,,PSTB(TT)]
	MOVE R,SYLT-2(A)	;POSSIBLE PIECE TAKEN
	LDB A,[DSMI,,PSTB(TT)]
	MOVE Q,SYLT-2(A)	;POSSIBLE DESTIN LOCN

;DROPS THRU;DROPS IN
AMBC:	CLEARM LGLMV
	LSH T,1
	MOVE J,SIDE
	AOS J
AMBC3:	JUMPE T,AMBC1
	JUMPG T,AMBC2
	PUSHJ P,CHK1
AMBC2:	LSH T,1
	AOJA J,AMBC3
AMBC1:	SKIPN A,LGLMV
	JRST AMBC4
	LDB D,[MPC,,A]
	SKIPL LMGT(D)
	JRST AMBC5	;NOT PAWN
	LDB D,[MPTO,,A]
	CAIL D,3*BW
	CAIL D,9*BW
	JRST RPROMP	;PROMOTED PAWN
AMBC5:	SKIPN PROMPC
	JRST POPJ1
AMBC4:	PTTY [ASCII /IMPOSSIBLE!/]
	JRST RMERR

RPROMP:	MOVE B,PROMPC
;	SKIPN B,PROMPC
;	JRST RMERR2
	TRO B,4
	DPB B,[300,,A]
	MOVEM A,LGLMV
	JRST POPJ1

RMOVE4:	MOVEI A,1
	CAIE D,2
	MOVEI A,2
	SKIPE SIDE
	TLO A,200000
	JRST POPJ1


CHK1:	PUSH P,J
	PUSH P,I
	JUMPL I,CHK2
	HRRZ S,I
	CAME S,PIECEL(J)
	JRST CHK1A	;LOCN DOESNT AGREE
CHK2:	PUSH P,B
	PUSH P,A
	PUSH P,Q
	MOVE B,J
	JUMPL Q,CHK3	;NO DESTIN SQ
	PUSH P,Q
	HRRZ A,Q
	PUSHJ P,LGLMP
	HLLZS (P)
	HLRZ A,(P)
	PUSHJ P,LGLMP
	HRRZS (P)
	POP P,Q
	JUMPE Q,CHK2R

CHK3:	SKIPL TAKES
	JRST FM1	;LEGAL MOVE 
	PUSH P,R	;CHECK CAPTURED PIECE
	MOVE C,SIDE
	XORI C,NPCS
	AOS C
	JUMPGE R,CHK3C1	;NOT GHOST
	SKIPN A,GHLOC
	JRST CHK3C1
	PUSHJ P,LGLMP
	JRST CHK3C1
	MOVE Q,GHLOC
	POP P,R
	JRST FM1

CHK3C1:	LSH R,1
CHK3C:	JUMPE R,CHK3R
	JUMPG R,CHK3A
	MOVE A,PIECEL(C)
	JUMPL Q,CHK3D
	CAIN A,(Q)
	JRST CHK3D
	MOVSS Q
	CAIE A,(Q)
	JRST CHK3A
CHK3D:	PUSHJ P,LGLMP
	JRST CHK3A

	PUSHJ P,FM4A
CHK3A:	LSH R,1
	AOJA C,CHK3C


CHK3R:	POP P,R
CHK2R:	POP P,Q
	POP P,A
	POP P,B
CHK1R:	POP P,I
	POP P,J
	POPJ P,

CHK1A:	HLRZ S,I
	CAME S,PIECEL(J)
	JRST CHK1R
	JRST CHK2

FM1:	JUMPL Q,RMERR2
	TRNN Q,-1
	MOVSS Q
	TLNE Q,-1
	JRST RMERR2
	SKIPE LGLMV
	JRST RMERR2
	SKIPE C,BOARD(Q)
	JRST FM2
	MOVEI A,0
	DPB J,[MPC,,A]
	SKIPE SIDE
	TLO A,200000
	MOVE S,PIECEL(J)
	DPB S,[MPO,,A]
	DPB Q,[MPTO,,A]
	MOVEM A,LGLMV
	JRST CHK2R

FM2:	MOVEI C,-PIECE(C)
	PUSHJ P,FM4
	JRST CHK2R

FM4A:	SKIPE LGLMV
	JRST RMERR3	;AMB
FM4:	MOVSI A,(SETZ)
	DPB J,[MPC,,A]
	SKIPE SIDE
	TLO A,200000
	MOVE S,PIECEL(J)
	DPB S,[MPO,,A]
	DPB C,[MPTK,,A]
	MOVE S,PIECEL(C)
	DPB S,[MPTO,,A]
FM5:	MOVEM A,LGLMV
	POPJ P,


RMERR3:
RMERR2:	PTTY [ASCII /AMBIGUOUS!/]
	SETOM DISSUP
	MOVE P,RMERR1
	POPJ P,

LGLMP:	SKIPE S,PIECEL(B)	;LEGAL FOR PIECE B TO MOVE TO SQ A
LGLMP2:	SKIPGE T1,BOARD(A)
	POPJ P,
	JUMPE T1,@LGLMPT(B)
	MOVE T2,(T1)
	XOR T2,PIECE(B)
	JUMPGE T2,CPOPJ	;OUR GUY THERE NOW
	JRST @LGLMPT(B)

FLGLMP:	SKIPE S,PIECEL(B)	;DONT CONSIDER WHAT PIECE IS IN DESTIN SQ
	SKIPGE T1,BOARD(A)
	POPJ P,
	SKIPL LMGT(B)	;SKIP ON PAWN
	JRST @LGLMPT(B)
	SKIPGE PIECE(B)
	JRST FLGLP1
	CAIN A,BW+1(S)
	JRST POPJ1
	CAIN A,BW-1(S)
	AOS (P)
	POPJ P,

FLGLP1:	CAIN A,-BW+1(S)
	JRST POPJ1
	CAIE A,-BW-1(S)
	POPJ P,
	AOS (P)
	POPJ P,


LWPWN:	CAIN A,BW(S)
	JRST LWPW1
	CAIN A,2*BW(S)
	JRST LWPW2
	CAIE A,BW+1(S)
	CAIN A,BW-1(S)
	JRST LWPW3
	POPJ P,

LWPW2:	CAIL S,4*BW
	POPJ P,
	SKIPN BOARD+2*BW(S)
LWPW1:	SKIPE BOARD+BW(S)
	POPJ P,
POPJ1:	AOS (P)
	POPJ P,

LWPW3:	SKIPE BOARD(A)
	JRST POPJ1	;SQUARE OCC + ITS NOT OUR GUY + ON BOARD
	SKIPGE GHSD
	CAME A,GHLOC
	POPJ P,
	AOS (P)
	POPJ P,

LBPWN:	CAIN A,-BW(S)
	JRST LBPW1
	CAIN A,-2*BW(S)
	JRST LBPW2
	CAIE A,-BW+1(S)
	CAIN A,-BW-1(S)
	JRST LBPW3
	POPJ P,

LBPW2:	CAIG S,8*BW
	POPJ P,
	SKIPN BOARD-2*BW(S)
LBPW1:	SKIPE BOARD-BW(S)
	POPJ P,
	AOS (P)
	POPJ P,

LBPW3:	SKIPE BOARD (A)
	JRST POPJ1
	SKIPLE GHSD
	CAME A,GHLOC
	POPJ P,
	AOS (P)
	POPJ P,

LROOK:	MOVEM S,LBSS
	MOVSI T2,-4
LROOK1:	MOVE S,LBSS
LROOK4:	ADD S,RDT(T2)
	SKIPGE T1,BOARD(S)
	JRST LROOK2
	CAMN A,S
	JRST LROOK5
	JUMPE T1,LROOK4
	CAIN T1,PIECE(B)
	JRST LROOK4	;DONT ALLOW PIECE TO BE BLOCKED BY ITSELF
			;POSSIBLE ON CALL FROM LR3A
LROOK2:	AOBJN T2,LROOK1
	MOVE S,LBSS
	POPJ P,

LROOK5:	MOVE S,LBSS
	AOS (P)
	POPJ P,

LQUEEN:	PUSHJ P,LROOK
	JRST .+3
	JRST POPJ1
LBIS:	MOVEM S,LBSS
	MOVSI T2,-4
LBIS1:	MOVE S,LBSS
LBIS4:	ADD S,BDT(T2)
	SKIPGE T1,BOARD(S)
	JRST LBIS2
	CAMN A,S
	JRST LROOK5
	JUMPE T1,LBIS4
	CAIN T1,PIECE(B)
	JRST LBIS4
LBIS2:	AOBJN T2,LBIS1
	MOVE S,LBSS
	POPJ P,


LKNT:	CAIE A,2*BW+1(S)
	CAIN A,2*BW-1(S)
	JRST POPJ1
	CAIE A,-2*BW+1(S)
	CAIN A,-2*BW-1(S)
	JRST POPJ1
	CAIE A,BW+2(S)
	CAIN A,BW-2(S)
	JRST POPJ1
	CAIE A,-BW+2(S)
	CAIN A,-BW-2(S)
	JRST POPJ1
	POPJ P,


LKING:	CAIE A,BW+1(S)
	CAIN A,BW-1(S)
	JRST POPJ1
	CAIE A,BW(S)
	CAIN A,-BW(S)
	JRST POPJ1
	CAIE A,1(S)
	CAIN A,-1(S)
	JRST POPJ1
	CAIE A,-BW-1(S)
	CAIN A,-BW+1(S)
	JRST POPJ1
	POPJ P,

LBSS:	0


;;INPF
ASTOP:	SETOM CLKCOK
	POPJ P,

ARST:	PUSHJ P,AUREAD
ARST1:	SETOM UREADF
	POPJ P,

AREPLAY:	MOVSI T2,600000
	JRST AFILR2

IFE DECTS,[

IFN UTAPE,[
IFN TS,[
ARDB:	SKIPA T2,[400000,,4]	;READ BINARY
AWRB:	MOVEI T2,5	;WRITE BINARY
	JRST AFILR2

AWRBB:	MOVEI T2,7	;WRITE BLOCK BINARY
	JRST AFILR2

ARDBB:	SKIPA T2,[400000,,6]	;READ BLOCK BINARY
]
IFE TS,AWRB:	;NO DIFFERENCE IN OPEN FOR BINARY OUT OF TS
AWRT:	MOVEI T2,1
	JRST AFILR2

AFILE:	TDZA T2,T2

IFE TS,ARDB:	;NO DIFFERENCE IN OPEN FOR BINARY OUT OF TS
AUREAD:	MOVSI T2,400000
AFILR2:	MOVEM T2,READF
	PUSHJ P,FSYL
	JRST UREDE
AURD1:	MOVSI A,(SETZ)
	MOVEM A,CFILE
	MOVEM B,CFILE+1
	PUSHJ P,FSYL
	JRST UREDE
	EXCH B,CFILE+1
	MOVEM B,CFILE
	PUSHJ P,FSYL
	JRST UREDE
IFE TS,[
	MOVE A,T1
	PUSHJ P,TAPKIL"
	EXCH A,TAPN
	PUSHJ P,TAPKIL
]	;CLOSE TS
IFN TS,[
	HLRM B,TAPN
	SKIPE B
]	;CLOSE TS
UREDE:	MOVE A,TAPN
	PUSHJ P,FILEST"
	JRST UNAB
	MOVE A,CFILE
	MOVE B,CFILE+1
	MOVE C,READF
IFN TS,	HRLM C,UTIN
	JUMPGE C,UWRR	;WRITE
	PUSHJ P,OPNRD"
	JRST FNF
	MOVE C,READF
	TLNN C,200000
	JRST PSRET	;RETURN IF NOT REPLAY
	CLEARM RWPF	;REPLAY
	CLEARM RBPF
	PTTY [ASCII /PLAY WHITE? !/]
	PUSHJ P,RDYON
	SETOM RWPF
	PTTY [ASCII /
BLACK? !/]
	PUSHJ P,RDYON
	SETOM RBPF
	PTTY [ASCIZ /
FROM PLY #? /]
	PUSHJ P,GETNUM
	MOVEM C,RPLYPN
	MOVEI A,ARPLY
	MOVEM A,GSW
	SKIPE CLKSW
	AOSE CLKCOK
	JRST ARST1
	CLEARM MACCLR
	PTTY [ASCII /CLOCK STARTED!/]
	JRST ARST1

FNF:	PTTY [ASCII /FILE NOT FOUND!/]
	MOVE P,RMERR1
	POPJ P,

UNAB:	ERRTTY [ASCII /UNIT UNABLE!/]

READF:	0	;-1 READ 0 WRITE 1 FILE

UWRR:	JUMPE C,AFILR1
	PUSHJ P,OPNWR"
	ERRTTY [ASCII /DIR FUL!/]
	POPJ P,

ASAVE:	PUSHJ P,AWRT
	MOVEI B,UWD
	SKIPE TMSPOT
	SOUT SPOTSW
	SETOM PMRDF
	PUSHJ P,APG6
AFILR1:	MOVE A,CFILE
	MOVE B,CFILE+1
	PUSHJ P,FILE"
	PTTY [ASCII /U LOSE!/]
	POPJ P,

RDYON:	PUSHJ P,TYI
	CAIN A,"N
	JRST POPJ1
	CAIN A,"Y
	POPJ P,
	MOVEI A,"?
	PUSHJ P,TYO
	JRST RDYON

FSYL:	SKIPE TERMF
	POPJ P,
	CLEARB T1,B
	MOVE C,[10600,,B-1]
FSYL1:	PUSHJ P,TYI
	CAIN A,177
	JRST GERR
	CAIN A,";
	JRST FSYL3
	CAIG A,40
	JRST FSYL2
	IMULI T1,10.
	ADDI T1,-"0(A)
	SUBI A,40
	TLNE C,770000
	IDPB A,C
	JRST FSYL1

FSYL2:	CAIE A,40
	SETOM TERMF
	CAMN C,[10600,,B-1]
	JRST FSYL
	JRST POPJ1

FSYL3:	.SUSET [.SSNAM,,B]
	JRST FSYL
TERMF:	0

CFILE:	SIXBIT /BOOK/
	SIXBIT /MOVES/

TAPN:	IFE TS,	2
	IFN TS, (SIXBIT /DSK/)
IFN TS,[
TAPKIL=CPOPJ
FILEST:	HRRM A,UTIN
	JRST POPJ1

OPNRD:	MOVEM A,UTIN+1
	MOVEM B,UTIN+2
	.OPEN UTYIC,UTIN
	POPJ P,
	JRST POPJ1

UTIN:	(SIXBIT /DSK/)
	SIXBIT /TEST/
	SIXBIT /GAME/

OPNWR:	MOVEM A,UTIN+1
	MOVEM B,UTIN+2
	.OPEN UTYOC,UTIN
	POPJ P,
	JRST POPJ1

FILE:	.CLOSE UTYOC,
	JRST POPJ1
]
]

]

IFN DECTS,[

AFILE:	PUSHJ P,AFILER
AFILEW:	RELEASE UTYOC,
	SETZM UTINT
	POPJ P,

AFILER:	RELEASE UTYIC,
	SETZM UREADF
	POPJ P,

AWRT:	SETZM UTINT
	PUSHJ P,GFILE
	INIT UTYOC,1
DEVNAM:	SIXBIT /FOOBAR/
	UTYOO,,0
	ERRTTY [ASCII /DEVICE NOT AVAILABLE!/]
	ENTER UTYOC,CFILE
	ERRTTY [ASCII /DIRECTORY FULL!/]
	MOVEI T1,UTYOB
	EXCH T1,JOBFF
	OUTBUF UTYOC,1
	MOVEM T1,JOBFF
	OUTPUT UTYOC,
	SETOM UTINT
	POPJ P,

UTYOO:	BLOCK 3
UTYOB:	BLOCK 203
UTINT:	0

AUREAD:	SETZM UREADF
	PUSHJ P,GFILE
	MOVE A,DEVNAM
	MOVEM A,DEVNM1
	INIT UTYIC,1
DEVNM1:	SIXBIT /FOOBAR/
	0,,UTYII
	ERRTTY [ASCII /DEVIDE NOT AVAILABLE!/]
	LOOKUP UTYIC,CFILE
	ERRTTY [ASCII /FILE NOT FOUND!/]
	MOVEI T1,UTYIB
	EXCH T1,JOBFF
	INBUF UTYIC,1
	MOVEM T1,JOBFF
	SETOM UREADF
	POPJ P,

UTYII:	BLOCK 3
UTYIB:	BLOCK 203

CFILE:	SIXBIT /CHESS/
	SIXBIT /MVS/
	0
	0

GFILE:	SETZM CFILE+3
	SETZM TERMF
	PUSHJ P,FSYL
	MOVEM B,DEVNAM
	PUSHJ P,FSYL
	MOVEM B,CFILE
	CAIE A,".
	POPJ P,
	PUSHJ P,FSYL	;GET FILENAME EXTENSION
	HLLM B,CFILE+1	;...
	POPJ P,	;TRA 1,4

TERMF:	0

FSYL:	SKIPE TERMF
	JRST GERR
	SETZB T1,B
	MOVE C,[10600,,B-1]
FSYL1:	PUSHJ P,TYI
	CAIN A,177
	JRST GERR
	CAIE A,".
	CAIN A,":
	JRST FSYL21
	CAIG A,40
	JRST FSYL2
	IMULI T1,10.
	ADDI T1,-"0(A)
	SUBI A,40
	TLNE C,770000
	IDPB A,C
	JRST FSYL1

FSYL2:	CAIE A,40
	SETOM TERMF
FSYL21:	CAMN C,[10600,,B-1]
	JRST FSYL
	POPJ P,

ASAVE:	PUSHJ P,AWRT
	MOVEI B,UWD
	SETOM PMRDF
	SETZM DISPGF
	PUSHJ P,APG6
AFILR1:	JRST AFILEW

]

;;;AFTR

AHBPT:	PUSHJ P,GETNUM
	MOVEM C,HBPTSW
	JUMPE C,AHBPT1
	LDB I,[100,,PLYN]
	PUSHJ P,HASHR
	JFCL
	MOVEM S,HSBPT
	POPJ P,

AHBPT1:	CLEARM HSBPT
	POPJ P,


IFN 0,[
NAAFTT:	PUSHJ P,GETNUM	;TRACE PMG AFTER ON NTH MULT SEARCH
	MOVEM C,AFMSST
	JRST AAFTT2

AAFTT:	SETZM AFMSST	;TRACE PMG AFTER
AAFTT2:	SETOM PMGTRF
	JRST AAFTT1

NAFTER:	PUSHJ P,GETNUM	;DO AFTER ON NTH MULT SEARCH
	MOVEM C,AFMSST
	JRST NAFT1

AAFTER:	SETZM AFMSST	;ORDINARY AFTER
NAFT1:	CLEARM PMGTRF
AAFTT1:	MOVE T,GAMP
	MOVEM T,AAFL
	SETOM BOOKF1	;SO SPACE=CR
AAFT3:	PUSHJ P,RMOVE
	PUSHJ P,IMMOVE
	JRST AAFT1
	PUSHJ P,DISUP
	MOVE A,LCHAR
	CAIE A,15
	CAIN A,12
	JRST AAFT2
	JRST AAFT3

AAFT1:	PTTY [ASCII /ILLEGAL!/]
	JRST AAFT3

AAFT2:	SKIPL PMGTRF
	JRST AAFT2B
	MOVE A,@GAMP	;TRACE LAST MOVE IN LINE
	MOVEM A,PMGTMV
	PUSHJ P,UNMOVE
AAFT2B:	MOVE T2,GAMP
	SUB T2,AAFL
	JUMPE T2,PSRET
	MOVEM T2,AAFL	;DEPTH OF GIVEN LINE
	CLEARM AAFTB+1-1(T2)
AAFT2A:	MOVE A,@GAMP
	MOVEM A,AAFTB-1(T2)
	PUSH P,T2
	PUSHJ P,UNMOVE
	POP P,T2
	SOJG T2,AAFT2A
	PUSHJ P,DISUP
	JRST HACK1

]
PMGTMV:	0	;MOVE TO BE TRACED

;;MISC3

ALIST:	MOVE B,PNTS	;LIST ALL PSEUDOS
	PUSHJ P,DCRR
	MOVSI J,SYMPS-BKSMS
ALIST1:	MOVE D,SYMPS(J)
ALIST2:	LDB A,[600,,D]
	ADDI A,40
	CAIE A,40
	PUSHJ P,(B)
	LSH D,-6
	SKIPE D
	JRST ALIST2
	SKIPL D,PSDS(J)
	JRST ALIST3
	MOVEI A,"=	;STD I O
	TLNN D,200000
	JRST ALIST5	;STD O
ALIST4:	PUSHJ P,(B)
	MOVE A,(D)
	PUSHJ P,DPT
ALIST3:	PUSHJ P,DCRR
	SKIPL QTF
	AOBJN J,ALIST1
	POPJ P,

ALIST5:	MOVEI A,"-
	SOS D
	JRST ALIST4

ASTEST:	PUSHJ P,GETNUM
	MOVEM C,EST
	SETOM ESTSW
	MOVE T1,PLYN
	MOVEM T1,SETESP
	POPJ P,

HK1V:	4
PSRET:	POPJ P,

ASETP:	SKIPA I,[-SBRLNG,,PSBR]
ASETW:	MOVE I,[-SBRLNG,,SBR]
	SKIPE EQSGNF
	JRST ASETWA
ASETW1:	PUSHJ P,GETNUM
	JUMPLE C,ASETW1
	MOVEM C,(I)
	AOBJP I,ASETW2
	SKIPN GME
	JRST ASETW1
ASETW2:	JUMPG I,CPOPJ
ASETW6:	MOVE A,-1(I)
	MOVEM A,(I)
	AOBJN I,ASETW6
	POPJ P,

ASETWA:	MOVEI B,TYO
	JRST ASETW5

PSETP:	SKIPA I,[-SBRLNG,,PSBR]
PSETW:	MOVE I,[-SBRLNG,,SBR]
ASETW5:	HLRO A,I
	MOVNS A
	ADDI I,-1(A)
	ADD I,[1,,]
	PUSHJ P,DSPACE
	SETZM ASTWF
	PUSH P,[0]
ASETW3:	MOVE A,-1(I)
	CAME A,(I)
	SETOM ASTWF
	SKIPE ASTWF
	PUSH P,(I)
	ADDI I,-1
	JUMPL I,ASETW3
ASETW4:	PUSHJ P,DPTS
	POP P,A
	JUMPE A,CPOPJ
	JRST ASETW4

ASTWF:	0

;;PARS

IFE DECTS,[
ASPARM:	PUSHJ P,GETNUM
	CAIL C,NPARS
	JRST ASPAR1
	MOVE T1,HK1V
	MOVEM T1,PARD(C)
	MOVE T1,FDCUT
	MOVEM T1,PARF(C)
	MOVE T1,PCGSW
	MOVEM T1,PARCG(C)
	IMULI C,SBRLNG
	MOVSI T1,SBR
	HRR T1,PARW(C)
	HRRZ T2,T1
	BLT T1,SBRLNG-1(T2)
	POPJ P,

ASPAR1:	PTTY [ASCII /ILLEGAL PARAMETER SET!/]
	POPJ P,
]
GETNUM:	MOVEI C,0
	SETZM GME
	JRST GSYLN1

PBOARD:	MOVE B,PNTS
	JRST BDOUT

ECHOS:	1


;;BOOK

IFN BOOK,[
BYMG:	MOVE C,[440600,,B]
	MOVEI B,0
BYMG2:	PUSHJ P,RCHA
	CAILE A,40
	CAILE A,140
	JRST BYMG1
	SUBI A,40
	TLNE C,770000
	IDPB A,C
	JRST BYMG2

BYMG1:	MOVE ZR,B
	MOVEI Q,0

BYMG4:	CAMN B,BKSMT(Q)
	POPJ P,	;FOUND TAG
	CAMGE Q,BSYMPR
	AOJA Q,BYMG4
	JRST POPJ1	;TAG NOT THERE

BKPUTI:	AOS C,BKFS
BKPUT:	CAIL C,BKSS
	ERRTTY [ASCII /BOOK FULL!/]
	IDIVI C,6
	DPB A,BKPT(D)
	POPJ P,

BKPT:	360600,,BBK(C)
	300600,,BBK(C)
	220600,,BBK(C)
	140600,,BBK(C)
	60600,,BBK(C)
	600,,BBK(C)

BSYMPR:	-1
BKFS:	0
BOOKF1:	0	;IN BOOK READIN IN -1
BKTM1:	0
BKTM2:	0
BKTM3:	0
BKF2R:	0	;FLAG TO LMG TO RETN TO VARIOUS HACKS IF .NE. 0
BOOKF3:	0	;MAKE MOVE FLAG


BKV:	PUSHJ P,BYMG
	JRST BKV1	;MDV
	AOS A,BSYMPR
	CAIL A,BMXS
	ERRTTY [ASCII /BOOK SYM TABLE FULL!/]
	MOVEM B,BKSMT(A)
	MOVE B,BKFS
	HRL B,PLYN
	MOVEM B,BKSMTV(A)
	JRST BKML

BKV1:	PTTY [ASCII /MDT!/]

BKV2:	MOVEI A,0
	ROTC ZR,6
	JUMPE A,BKML
	ADDI A,60
	PUSHJ P,TYO
	JRST BKV2

BKT:	PUSHJ P,BYMG
	JRST BKT1
	PTTY [ASCII /UNDEFINED GO TO!/]
	JRST BKV2

BKT1:	MOVEI A,76
	PUSHJ P,BKPUTI
	LDB A,[60600,,Q]
	PUSHJ P,BKPUTI
	LDB A,[600,,Q]
	PUSHJ P,BKPUTI
	JRST BKT2

BKE:	MOVEI A,77
	PUSHJ P,BKPUTI

BKT2:	SKIPN PLYN
	JRST MNLP2
	PUSHJ P,UNMOVE
	JRST BKML


BKM:	PUSHJ P,BYMG
	JRST BKM1
	PTTY [ASCII /UNDEFINED MULTIPLE END!/]
	JRST BKV2

BKM1:	HLRZ D,BKSMTV(Q)
	CAMLE D,PLYN
	JRST BKM2
	CAMN D,PLYN
	JRST BKML
	AOS C,BKFS
	MOVEI A,77
	PUSHJ P,BKPUT
	PUSH P,Q
	PUSHJ P,UNMOVE
	POP P,Q
	JRST BKM1

BKM2:	PTTY [ASCII /ATTEMPT TO RETURN TO HIGHER PLYN!/]
	JRST BKV1

IFE DECTS,[
AWBKB:	PUSHJ P,AWRB
	MOVE A,BKFS
	IDIVI A,6
	MOVNI A,1(A)
	HRLZS B,A
	PUSHJ P,UWRB
	MOVE A,BBK(B)
	PUSHJ P,UWRB
	AOBJN B,.-2
	MOVE B,BSYMPR
	MOVNI B,1(B)
	HRLZS B
	MOVE A,B
	PUSHJ P,UWRB
	MOVE A,BKSMTV(B)
	PUSHJ P,UWRB
	AOBJN B,.-2
	PUSHJ P,AFILR1
	JRST PSRET

ARBKB:	PUSHJ P,ARDB
	PUSHJ P,UREDB
	HLRO C,A
	IMULI C,-6
	HRRZM C,BKFS	;SO RIGHT THING WILL HAPPEN ON SUBSEQUENT WRITEOUT
	MOVE B,A
	PUSHJ P,UREDB
	MOVEM A,BBK(B)
	AOBJN B,.-2
	PUSHJ P,UREDB
	MOVE B,A
	HLROS A
	MOVNI A,1(A)
	HRRZM A,BSYMPR
	PUSHJ P,UREDB
	MOVEM A,BKSMTV(B)
	AOBJN B,.-2
IFN TS,	.CLOSE UTYIC,
	JRST PSRET

]

ARBOOK:	SETOM BSYMPR
	CLEARM BKSMT
	CLEARM BKFS	;RESET BOOK
ACBOOK:	SETOM BOOKF1

BKML:	MOVE P,[-PDLL,,PDL-1]
	PUSHJ P,RMOVE
	JRST .-1
	PUSHJ P,BKFND
	ERRTTY [ASCII /MOVE NOT FOUND!/]
BKME2:	CAIL C,75
	JRST BKME3
	MOVE A,C
	PUSHJ P,BKPUTI
	MOVE A,BKTM1
	PUSHJ P,IMMOVE
	ERRTTY [ASCII /ILLEGAL!/]
IFN DSPLY,	PUSHJ P,DISUP
	JRST BKML

BKMM:	SETOM BOOKF3
	MOVEM B,BKTM3	;GET PIECE TO SQUARE FOR MOVE NO IN A
	LDB I,[100,,PLYN]
	JRST BKMM2
BKFND:	CLEARM BOOKF3
	MOVEM A,BKTM1
	LDB I,[420100,,A]
BKMM2:	MOVEI A,BKME	;RET MOVE NO IN C THAT CORRESP TO STANDARD MOVE IN A
	PUSH P,BKF2R
	MOVEM A,BKF2R
	MOVEM P,BKTM2
	PUSHJ P,LMG
	ERRTTY [ASCII /LMG RETURNED!/]

BKME:	HRRZ A,PMVORG
	AOS A
	SKIPGE BOOKF3
	JRST BKMM1
	LDB T1,[MPC,,BKTM1]
	LDB T2,[MPTO,,BKTM1]
	MOVEI C,0
BKMEL:	CAIN A,1(P)
	JRST BKME5
	LDB D,[300,,BKTM1]
	LDB B,[170300,,(A)]
	CAIN D,3
	JRST BKMEL2
	CAME B,D
	JRST BKMEL1
BKMEL2:	HRRZ B,(A)
	ANDI B,177
	CAME B,T2
	JRST BKMEL1
	HLRZ B,(A)
	CAMN B,T1
	JRST BKME4
BKMEL1:	ADDI A,NWDPM
	AOJA C,BKMEL

BKME4:	MOVE P,BKTM2
	POP P,BKF2R
	MOVE A,BKTM1
	JRST POPJ1

BKME5:	MOVE P,BKTM2
	POP P,BKF2R
	MOVE A,BKTM1
	POPJ P,

BKMM1:	REPEAT NWDPM,ADD A,BKTM3
	CAIL A,1(P)
	ERRTTY [ASCII /MOVE NUMBER TOO HIGH--BKMM!/]
	MOVE B,(A)
	JRST BKME5

BKME3:	PUSH P,C
	MOVEI A,75
	PUSHJ P,BKPUTI
	POP P,C
	SUBI C,75
	JRST BKME2
]


;;;DRAW
ADRAW:	MOVEI B,TYO
	PUSHJ P,GLV
	SKIPE MACCLR
	MOVNS T1
	MOVE T2,PLYN
	CAIG T2,20
	JRST ADRWD
	CAIG T2,50
	CAMG T1,[-105]
	SKIPA
	JRST ADRWD
	CAIL T1,105
	JRST ADRWD
	SOUT [ASCII / ACCEPT !/]
	POPJ P,

ADRWD:	SOUT [ASCII / DECLINE !/]
	POPJ P,

GLV:	MOVEI T1,0
	MOVE T2,GAMP	;RETURN LAST POS VAL IN T1
GLV1:	CAIN T2,GAME-1
	POPJ P,
	SKIPGE T1,GAMEV-GAME(T2)
	SOJA T2,GLV1
	HRRES T1
	POPJ P,

IFE DECTS,[
IFN DEC-TS,	PILPT:	POPJ P,
IFN TS,[PILPT:	CAIL A,40
	AOS LINEPOS
	CAIN A,11
	JRST PILPTB
	CAIE A,15
	JRST PILPT1
	SKIPN ALNBP
	JRST PILPT2
PILPT4:	MOVEI A,40
	PUSHJ P,PILPT1
	AOS A,LINEPOS
	CAMLE A,AUXLNP
	JRST PILPT7
	CAML A,AUXLNP
	JRST PILPT3
	JRST PILPT4

PILPT7:	MOVEI A,15
	PUSHJ P,PILPT1
	MOVEI A,12
	PUSHJ P,PILPT1
	CLEARM LINEPOS
	JRST PILPT4

PILPT3:	CLEARM LINEPOS
PILPT6:	ILDB A,ALNBP
	JUMPE A,PILPT5
	PUSHJ P,PILPT1
	CAIE A,15
	JRST PILPT6
	POPJ P,

PILPTB:	PUSH P,A
	MOVE A,LINEPOS
	ANDCMI A,7
	ADDI A,10
	MOVEM A,LINEPOS
	POP P,A
	JRST PILPT1

PILPT5:	CLEARM ALNBP
	MOVEI A,15
PILPT2:	CLEARM LINEPOS
PILPT1:	.IOT LPTC,A
	POPJ P,

ALNBP:	0	;BYTE PNTR AUX LPT
AUXLNP:	0	;COL # TO START AUX LPT
AUXLPP:	0	;BYTE PNTR (INPUT)
AUXLPB:	BLOCK 75.	;BUFFER FOR HOLDING CRUFT

AUXLRS:	SKIPN ALNBP
	JRST AUXLR1
	PUSH P,A
	MOVEI A,15
	PUSHJ P,PILPT
	POP P,A
	JRST AUXLRS

AUXLR1:	MOVEM A,AUXLNP	;RESET AUX LINE LPT (START AT COL IN A)
	MOVE A,[440700,,AUXLPB]
	MOVEM A,AUXLPP
	MOVEM A,ALNBP
	POPJ P,

AUXLPT:	CAIE A,12
	IDPB A,AUXLPP
	PUSH P,A
	PUSH P,AUXLPP
	MOVEI A,0
	IDPB A,AUXLPP
	POP P,AUXLPP
	POP P,A
	POPJ P,
]
]

IFN DECTS,[
PILPT:	SKIPN LPTINT
	POPJ P,
	AOS LINEPOS
	CAIN A,15
	SETZM LINEPOS
	SOSG LPTO+2
	OUTPUT LPTC,
	IDPB A,LPTO+1
	POPJ P,
]

;;MISC
ASPOT:	SKIPN PLYN	;SETS ODDS FROM STRING ARGUMENT AFTER RESETING
	JRST ASPOT1
	PUSHJ P,UNMOVE	;P N B R Q  FLUSH KBP QN QB QR Q  FOR SIDE SET TO
	JRST ASPOT	;V  CHANGES SIDE.  INITIALLY WHITE
ASPOT1:	PUSHJ P,BDINI	;R  ALSO MOVES QRP-R3
IFN DSPLY,	PUSHJ P,DISUP
	CLEARM TMSPOT
	MOVE Q,[TMSPOT,,TMSPOT+1]
	BLT Q,TMSPOT+3
	MOVE Q,[440700,,TMSPOT]
	SKIPE GME
	JRST ASPOTX
	SETZM ASSIDE
ASPOT2:	PUSHJ P,RCHA
	CAIGE A,40
	JRST ASPOTX
	CAIN A,40
	JRST ASPOT2
	MOVEI T1,0
IRPC X,,BNPQRV
	CAIN A,"X
	JRST ASPOT!X
	TERMIN
ASPOT3:	PUSHJ P,QMTYO
	JRST ASPOT2

ASSIDE:	0

SPOTSW:	ASCII /SPOT /
TMSPOT:	BLOCK 4

ASPOTR:	SKIPE ASSIDE
	JRST ASPOT4
	MOVEI T1,4*BW+8
	MOVEM T1,PIECEL-PIECE+WKR-1
	SETZM BOARD+3*BW+8
	MOVEI T1,WKR-1
	MOVEM T1,BOARD+4*BW+8
	AOS NMOVES+WKR-1-PIECE
	JRST ASPOT5
ASPOT4:	MOVEI T1,7*BW+8
	MOVEM T1,PIECEL-PIECE+WKR-1+BPV-1
	SETZM BOARD+8*BW+8
	MOVEI T1,WKR-1+BPV-1
	MOVEM T1,BOARD+7*BW+8
	AOS NMOVES+WKR-1+BPV-1-PIECE
ASPOT5:	MOVEI T1,WQR-<WKR-6>
ASPOTP:	ADDI T1,<WKR-6>-<WKING+2>
ASPOTB:	ADDI T1,<WKING+2>-<WKING+3>
ASPOTN:	ADDI T1,<WKING+3>-<WKING+1>
ASPOTQ:	ADDI T1,<WKING+1>
	SKIPE ASSIDE
	ADDI T1,BPV-1
	SKIPN T2,PIECEL-PIECE(T1)
	JRST ASPOT3
	IDPB A,Q
	MOVN A,PVALUE-PIECE(T1)
	CAIE T1,WKR-6+BPV-1
	CAIN T1,WKR-6
	JRST ASPOT8
	SKIPE ASSIDE
	ADDM A,PCBAL+1
	SKIPL ASSIDE
	ADDM A,PCBAL
	SOS @NPCP1-PIECE(T1)
ASPOT9:	SOS @NPCPT-PIECE(T1)
	SETZM PIECEL-PIECE(T1)
	SETZM BOARD(T2)
	SETZM UBKF	;BOOK BITES WITH ODDS
IFN DSPLY,	PUSHJ P,DISUP
	JRST ASPOT2

ASPOTV:	IDPB A,Q
	SETCMM ASSIDE
	JRST ASPOT2

ASPOTX:	PUSHJ P,.CAT1
	JRST ARS1

ASPOT8:	SKIPE ASSIDE
	ADDM A,PNBAL+1
	SKIPL ASSIDE
	ADDM A,PNBAL
	JRST ASPOT9

ARESET:	CLEARM HACKMX
	CLEARM HACKMN
	SKIPL GME
	JRST ARS2
	SETZM UNPLYN
	CLEARM HSTB
	MOVE A,[HSTB,,HSTB+1]
	BLT A,HSTB+HTNE-1
	MOVE A,HASHSS
	MOVEM A,HASHS
ARS3:	MOVE A,PLYN
	CAMN A,UNPLYN
	JRST ARS0
	PUSHJ P,UNMOVE
	JRST ARS3

UNPLYN:	0

ARS0:	SKIPE PLYN
	JRST ARS1
	CLEARM TMSPOT
	SETZM GHSD
	SETZM GHLOC
	PUSHJ P,BDINI
ARS1:	SETOM CLKCOK
	CLEARM WCLOCK
	CLEARM BCLOCK
	CLEARM QDCOF
	CLEARM PINVF+WKING+1-PIECE
	CLEARM PINVF+BKING+1-PIECE
IFN TS,[
	CLEARM WCLOCK+1
	CLEARM BCLOCK+1
]
IFE DECTS,[
	MOVEI A,OCLOCK
	MOVEM A,CURCLK
]
	MOVEI A,MNLPA
	MOVEM A,GSW
	PUSHJ P,.CAT
IFN BOOK,CLEARM BKLFT
	POPJ P,

ARS2:	PUSHJ P,GETNUM
	LSH C,1
	MOVEM C,UNPLYN
	JRST ARS3

.PNT:	0
PNT:	PUSHJ P,GETNUM
PNT2:	MOVEM C,.PNT
	MOVEI A,PIALPT
	SKIPN C
	MOVEI A,TYO
	SKIPGE C
	MOVEI A,PPA
	MOVEM A,PNTS
IFN TS,[
	JUMPLE C,PNT3
	.OPEN ALPTC,LPTF
	JRST PNT4
	POPJ P,

PIALPT:	.IOT ALPTC,A
	POPJ P,

PNT4:	SETZM .PNT
	MOVEI A,TYO
	MOVEM A,PNTS
	JRST GERR

PNT3:	.CLOSE ALPTC,
]	JRST PSRET

IFE TS,	PIALPT==PILPT

PNTS:	TYO


ACLEAR:	PUSHJ P,ARESET		;CLEAR BOARD COMPLETELY
	MOVE B,[-NPC,,1]
ACLR1:	MOVE A,PIECEL(B)
	JUMPE A,ACLR2
	CLEARM BOARD(A)
	CLEARM PIECEL(B)
	SOS @NPCPT(B)
	SOS @NPCP1(B)
	LDB I,[430100,,PIECE(B)]
	MOVN T2,PVALUE(B)
	SKIPL LMGT(B)
	XCT MMT4+1(I)
	SKIPGE LMGT(B)
	XCT MMT6+1(I)
	SKIPGE RFPCS(B)
	XCT MMT5+1(I)
ACLR2:	AOBJN B,ACLR1
.CAT1X:	PUSHJ P,ATEV
	JRST .CAT1

AWPOS:	PUSHJ P,AWRT
	MOVEI B,UWD
	SOUT [ASCIZ \RESET
RPOS
\]
	PUSHJ P,BDOUT
	LDB I,[100,,PLYN]
	XCT WSIDE(I)
	JRST AFILR1

WSIDE:	SOUT [ASCIZ /SIDE W
/]
	SOUT [ASCIZ /SIDE B
/]

ARPOS:	SKIPE PLYN
	JRST QMTYO
	SETOM GME
	PUSHJ P,ACLEAR
	MOVEI A,7
	MOVEM A,RKN
ARPOS2:	MOVEI A,7
	MOVEM A,FNN
ARPOS1:	PUSHJ P,RRSYL
	MOVE A,RKN
	IMULI A,BW
	ADD A,FNN
	ADDI A,2*BW+1
	PUSHJ P,ARPUT
	SKIPGE GME
	JRST ARPOS3
	SOSL FNN
	JRST ARPOS1
	PUSHJ P,TYI
ARPOS3:	SOSL RKN
	JRST ARPOS2
	JRST .CAT1X

RRSYL:	MOVE C,[440600,,B]
	CLEARB B,GME
RRSYL1:	PUSHJ P,TYI
	CAIN A,12
	JRST RRSYL1
	CAIG A,40
	JRST RRSYL2
	SUBI A,40
	TLNE C,770000
	IDPB A,C
	JRST RRSYL1

RRSYL2:	CAIN A,15
	SETOM GME
	JUMPE B,CPOPJ
	MOVSI C,ARPS1-ARPS2
RRSYL3:	CAMN B,ARPST(C)
	POPJ P,
	AOBJN C,RRSYL3
	MOVEI B,0
	POPJ P,

ARPUT:	JUMPE B,CPOPJ
	LDB Q,[100,,PLYN]
	MOVE B,ARPS1(C)
	TLNE B,40000
	JRST APUT5	;GHOST
	TLNE B,100000
	POPJ P,
	TLNE B,200000
	JRST APUT4	;BISHOP
APUT3:	MOVE D,(B)
	SKIPN PIECEL-PIECE(D)
	JRST APUT1	;FOUND PLACE TO PUT IT
	JUMPL D,APUT2
	AOJA B,APUT3

APT2T:	CAIN B,ARWPP+7
	CAMN B,[SETZ ARBPP+7]

APUT2:	SKIPL RPIECE-PIECE(D)
	XCT APT2T(I)
	ERRTTY [ASCIZ /CANT PUT PIECE /]
	LDB I,[430100,,(D)]
	MOVE B,ARPS1+10.(I)	;PUT PAWN
	PUSHJ P,APUT3
	MOVEI B,-PIECE(D)
	SKIPE @GAMP
	PUSHJ P,ASIDEB
APUTC:	MOVEI A,-2(C)
	LSH A,-1
	MOVE D,PIECEL(B)
	DPB B,[MPC,,A]
	DPB D,[MPTO,,A]
	DPB I,[420100,,A]
	SETOM DBSUPS
	PUSH P,ICSW
	SETZM ICSW
	PUSH P,Q
	PUSHJ P,MMS5P
	ERRTTY [ASCIZ /PUT?/]	;SHOULD BE SKIPPED OVER
	POP P,Q
	POP P,ICSW
	SETZM DBSUPS
	SETOM MOVST
	LDB A,[100,,PLYN]
	CAMN A,Q
	POPJ P,
ASIDEB:	AOS A,GAMP
	SETZM (A)
	SETZM GHK1-GAME(A)
	MOVSI ZR,(SETZ)
	MOVEM ZR,GAMEV-GAME(A)
	AOS PLYN
	POPJ P,

APUT1:	HRRZM A,PIECEL-PIECE(D)
	HRRZM D,BOARD(A)
	AOS @NPCPT-PIECE(D)
	AOS @NPCP1-PIECE(D)
	MOVE T2,PVALUE-PIECE(D)
	LDB I,[430100,,(D)]
	CLEARM NMOVES-PIECE(D)
	SKIPL LMGT-PIECE(D)
	XCT MMT4+1(I)
	SKIPGE LMGT-PIECE(D)
	JRST APUT6
APUT7:	SKIPGE RFPCS-PIECE(D)
	XCT UMT5+1(I)
	SKIPGE RPIECE-PIECE(D)
	AOS NMOVES-PIECE(D)	;NO CASTLING
	SETZM UBKF		;BOOK LOSES
	POPJ P,

APUT6:	XCT MMT6+1(I)
	XCT APUTO(I)	;SKIP IF PAWN ON SECOND RANK
	AOS NMOVES-PIECE(D)
	JRST APUT7

APUTO:	CAIL A,4*BW
	CAIGE A,8*BW

APUT4:	LDB D,[BCOLR,,BPREL(A)]	;SELECT APPRO COLOR B
	ADD B,D
	JRST APUT3

APUT5:	LDB D,[BRANK,,BPREL(A)]
	SKIPGE B
	MOVE D,REVERS(D)
	CAIN D,3
	SKIPE GHLOC
	ERRTTY [ASCIZ /CANT PUT GHOST/]
	HRRZM A,GHLOC
	MOVEI D,1
	SKIPGE B
	MOVNI D,1
	MOVEM D,GHSD
	SETOM MOVST	;DONT STORE MOVE FOR GHOST
	POPJ P,

APUT:	PUSHJ P,RRSYL
	JUMPE B,QMTYO
	PUSH P,B
	PUSH P,C
	CLEARM SIDE
	PUSHJ P,GSYL
	POP P,C
	POP P,B
	SKIPGE BOARD(A)
	MOVSS A
	SKIPE BOARD(A)
	JRST QMTYO
	SETZM MOVST
	PUSHJ P,ARPUT
	SKIPE MOVST
	JRST .CAT1X
	SKIPE @GAMP
	PUSHJ P,ASIDEB
	MOVEI B,-PIECE(D)
	MOVE D,PIECEL(B)
	DPB B,[MPC,,@GAMP]
	DPB D,[MPTO,,@GAMP]
	DPB I,[420100,,@GAMP]
	LDB A,[100,,PLYN]
	CAME A,Q
	PUSHJ P,ASIDEB
	JRST .CAT1X

MOVST:	0	;-1 IF MOVE ALREADY STORED

ARPST:	SIXBIT /WK/
	SIXBIT /BK/
	SIXBIT /WQ/
	SIXBIT /BQ/
	SIXBIT /WR/
	SIXBIT /BR/
	SIXBIT /WB/
	SIXBIT /BB/
	SIXBIT /WN/
	SIXBIT /BN/
	SIXBIT /WP/
	SIXBIT /BP/
	SIXBIT /--/
	SIXBIT /**/
	SIXBIT /WG/
	SIXBIT /BG/

ARPS1:	ARWKP
	SETZ ARBKP
	ARWQP
	SETZ ARBQP
	ARWRP
	SETZ ARBRP
	200000,,ARWBP
	600000,,ARBBP
	ARWNP
	SETZ ARBNP
	ARWPP
	SETZ ARBPP
	100000,,
	100000,,
	40000,,
	440000,,

ARPS2:
ARWKP:	SETZ WKING
ARBKP:	SETZ BKING
ARWQP:	SETZ WKING+1
ARBQP:	SETZ BKING+1
ARWRP:	WKR
	SETZ WQR
ARBRP:	BKR
	SETZ BQR
ARWBP:	SETZ WKR+2	;WHITE SQ B
	SETZ WQR-2	;BLACK SQ B
ARBBP:	SETZ BQR-2	;WHITE SQ B
	SETZ BKR+2	;BLACK SQ B
ARWNP:	WKR+1
	SETZ WQR-1
ARBNP:	BKR+1
	SETZ BQR-1
ARWPP:	REPEAT 7,PIECE+1+.RPCNT
	SETZ PIECE+1+7
ARBPP:	REPEAT 7,PIECE+NPCS+1+.RPCNT
	SETZ PIECE+NPCS+1+7

RKN:	0
FNN:	0

TXSID:	"W
	"B
	"W

ASIDE:	LDB I,[100,,PLYN]
	SKIPE EQSGNF
	JRST ASIDEA
	PUSHJ P,RCHA
	CAIN A,40
	JRST .-2
	CAMN A,TXSID(I)
	POPJ P,
	CAME A,TXSID+1(I)
	JRST RMERR
	JRST ASIDEB

ASIDEA:	MOVE A,TXSID(I)
	PUSHJ P,TYO
	POPJ P,

UNPUT:	JUMPE B,POPIJ
	SKIPE ICSW
	PUSHJ P,MMIC1
	SOS @NPCPT(B)
	SOS @NPCP1(B)
	SETZM BOARD(T)
	SETZM PIECEL(B)
	MOVN T2,PVALUE(B)
	SKIPL LMGT(B)
	XCT MMT4+1(I)
	SKIPGE LMGT(B)
	XCT MMT6+1(I)
	SKIPGE RFPCS(B)
	XCT MMT5+1(I)
	JRST POPIJ


WALLP:	-1
AWALLP:	PUSHJ P,GETNUM
AWALPR:	MOVEM C,WALLP
IFE TS+DECTS,	JRST PSRET
IFE DECTS,[
IFN TS,[	JUMPE C,AWALP1
	JUMPL C,AWALP3	;TO DISK
WALP2:	.OPEN LPTC,LPTF
	SKIPA
	POPJ P,
	SETZM WALLP
	JRST GERR

AWALP3:	.OPEN LPTC,LPTDSK
	JRST GERR
	POPJ P,

LPTDSK:	(1+SIXBIT /DSK/)
	SIXBIT /WALL/
	SIXBIT />/

LPTF:	(1+SIXBIT /LPT/)
	SIXBIT /WALL/
	SIXBIT /PAPER/

AWALP1:	.CLOSE LPTC,
	JRST PSRET
]

PPA:	IFE DEC-TS,[SKIPE WALLP
	PUSHJ P,PILPT]
UWD:
IFE TS,[
	PUSHJ P,UWR"
	PTTY [ASCII /TAPE FULL!/]
	POPJ P,

UWRB:	PUSHJ P,.UWR"
	PTTY [ASCII /TAPE FULL!/]
	POPJ P,
]
IFN TS,[
UWRB:	.IOT UTYOC,A
	POPJ P,
]
]

IFN DECTS,[
	SETZM LPTINT
	JUMPE C,AWALP1
	INIT LPTC,1
	SIXBIT /LPT/
	XWD LPTO,0
	JRST GERR
	ENTER LPTC,LPTFF
	JRST GERR
	OUTBUF LPTC,2
	SETOM LPTINT
	JRST PSRET
AWALP1:	RELEASE LPTC,
	JRST PSRET

LPTINT:	0
LPTO:	0
LPTFF:	SIXBIT /WALLPA/
	SIXBIT /PER/
	0
	0

PPA:	SKIPE WALLP
	PUSHJ P,PILPT
UWD:	SKIPN UTINT
	POPJ P,
	SOSG UTYOB+2
	OUTPUT UTYOC,
	IDPB A,UTYOB+1
	POPJ P,
]

;;;TRACE

APTRCE:	MOVEI I,3	;TRACE POSITIONAL FACTORS IN PMG
	JRST APTR1

ALTRCE:	CLEARB I,TRCSW1	;TRACE ALL MOVES
	MOVEI A,0
	JRST ALTRC1

ATRACE:	SKIPL GME
	TDZA I,I
	MOVEI I,1
APTR1:	MOVEM I,TRCSW1
	SKIPGE GME
	JRST ASTRC5	;TRACE STATEV
	PUSHJ P,RMOVE
	JRST MNLP2
ALTRC1:	LDB T1,[MPC,,A]	;ENTRY ON AFTER (PMG TRACE)
	MOVEM T1,TPIECE
	LDB T1,[MPTO,,A]
	MOVEM T1,TSQ
	MOVE I,TRCSW1
ASTRC1:	MOVE R,[-TPCHL,,TPATCH-1]	;ENTRY ON AFTER HACK STATEV (STVTR1)
	AOSE TSSW
	ERRTTY [ASCIZ /ALREADY PATCHED?/]
ATRL:	MOVE T1,ATRTT1(I)
ATRL1:	HLRZ T2,@ATRTT2(I)
	LDB C,[270400,,-1(T2)]	;AC OF INST TO BE PATCHED
	CAME C,ATSAC(I)	;SUMAC FOR THIS FLAVOR TRACE?
	JRST ATRL1B
ATRL1A:	LDB C,[331100,,-1(T2)]	;RIGHT AC, CAN INST WIN?
	MOVSI D,-LTUUT
	CAMN C,TUUT(D)
	JRST ATRL2	;YES REPLACE WITH APPRO UUO
	AOBJN D,.-2
ATRL1B:	MOVSI C,(12000,,)	;UUO 12 JUST PRINTS HACK
	HRRI C,@ATRTT2(I)	;INSERT PATCH
	PUSH R,C
	MOVSI D,(JRST)
	HRR D,R
	EXCH D,-1(T2)
	PUSH R,D	;STORE PATCHED INST IN PATCH SPACE
	ADD T2,[JRST]
	PUSH R,T2	;STORE RETURN
	AOS T2
	LDB C,[410300,,D]
	CAIE C,3
	CAIN C,6
	PUSH R,T2	;PATCHED INST MIGHT SKIP STORE RETURN+1
ATRL3:	AOBJN T1,ATRL1
	MOVE T1,ATSAC(I)
	MOVEM T1,TRSAC	;STORE SUM AC FOR UUO HACKER
	SKIPL ATRTT2(I)
	JRST ASTRC4	;DONT INSERT P.M.G. PATCHES (HACK STATEV INSTEAD)
	MOVE T1,[JRST ATRSS1]
	EXCH T1,TRS1
	MOVEM T1,ITRS1
	MOVE T1,[JRST ATRSS2]
	EXCH T1,TRS2
	MOVEM T1,ITRS2
	MOVE T1,[JRST ATRSS3]
	EXCH T1,TRS3
	MOVEM T1,ITRS3


IFN DSPLY,	PUSHJ P,DISINS
	MOVE A,[DBS1,,SDBS1]
	BLT A,SDBS2
	SETOM DBS1
	CLEARM DBS2
	JUMPL I,PMAF4	;WANT TO PICK UP IN PMG
	PUSH P,NHSW
	SETOM NHSW	;DONT CLOBBER HT
	PUSHJ P,HACK1
	POP P,NHSW
AFTR3:	MOVS A,[DBS1,,SDBS1]
	BLT A,DBS2
	MOVE I,TRCSW1
	MOVE T1,ITRS1
	MOVEM T1,TRS1
	MOVE T1,ITRS2
	MOVEM T1,TRS2
	MOVE T1,ITRS3
	MOVEM T1,TRS3
ASTRC3:	MOVE T1,ATRTT1(I)
AUTR1:	HLRZ T2,@ATRTT2(I)	;UNTRACE
	LDB C,[331100,,-1(T2)]
	CAIN C,JRST←-27.
	JRST AUTR2
	MOVE C,TUUT-4(C)
	DPB C,[331100,,-1(T2)]
AUTR3:	AOBJN T1,AUTR1
	SETOM TSSW
	IFN DSPLY,PUSHJ P,DISCLG
	SETOM DISSUP	;SO DISPLAY NOT CLOBBERED
	POPJ P,

ASTRC5:;	PUSHJ P,VALPRE	;INITIALIZE BUGGER FACTOR SWITCHES
	JRST ASTRC1

AUTR2:	HRRZ C,-1(T2)
	MOVE C,1(C)
	MOVEM C,-1(T2)
	JRST AUTR3


ATRL2:	MOVEI D,4(D)
	DPB D,[331100,,-1(T2)]
	JRST ATRL3

PMAF4:	MMRSAC	;RETURN TO PMG
	JRST PMAF2

ATRSS1:	SETOM TPSW	;IS THIS THE MOVE WE WANT?
	HRRZ T1,B
	SKIPN TSQ
	RC *P!B TO *S!A,JRST ITRS1	;WANT ALL
	CAMN A,TSQ
	CAME T1,TPIECE
	CLEARM TPSW
	SKIPE TPSW
TM:	JFCL	;BREAKPOINT HERE TO STOP PMG ON TRACED MOVE
ITRS1:	0
	JRST TRS1 1
	JRST TRS1 2

ATRSS2:	CLEARM TPSW
	HRRZ T1,B
	SKIPE TPIECE
	CAMN T1,TPIECE
TP:	SETOM TPSW	;BKPT HERE TO STOP ON TRACED PIECE
ITRS2:	0
	JRST TRS2+1
	JRST TRS2+2

ATRSS3:	PUSH P,B
	PUSH P,T1
	PUSH P,T2
	MOVE B,TRPSW
	SKIPL TPSW
	JRST ITRS3A
	SETOM ITRS3T
	MOVE T1,[-EGNNMS+BGNS,,1]
ITRS3C:	SKIPN BGNS-1(T1)
	JRST ITRS3E
	AOS T2,ITRS3T
	TRNN T2,7
	SOUT [ASCIZ /
/]
	SOUT @GANNTB-1(T1)
	MOVE T2,BGNS-1(T1)
	ISOUT 1,[.ASCII ? *U!T2 ?]
ITRS3E:	AOBJN T1,ITRS3C
	SOUT [ASCIZ /
/]
	MOVEI T1,MVDST
ITRS3B:	CAML T1,MVDSP
	JRST ITRS3A
	ISOUT [.ASCII ?*V!T1?]
	AOS T1
	AOJA T1,ITRS3B

ITRS3T:	0

ITRS3A:	POP P,T2
	POP P,T1
	POP P,B
	SKIPN TSQ
	JRST ITRS3D
ITRS3:	0
	JRST TRS3 1
	JRST TRS3 2

ITRS3D:	MMSAVA
IFN DSPLY,[
	PUSHJ P,DISCLG
	PUSHJ P,TYI
	PUSHJ P,DISINS
]
	MMRSAC
	JRST ITRS3

ASTRC4:	SETOM TPSW
IFN DSPLY,	PUSHJ P,DISINS
	CAIL I,2
	POPJ P,
	PUSHJ P,STINI
	LDB I,[100,,PLYN]
	PUSHJ P,STVL4
ATRAF1:RS TOTAL SUPER STATIC POSITION EVALUATION,MOVE I,TRCSW1
	JRST ASTRC3
TPIECE:	0	;PIECE MAKING MOVE TO BE TRACED
TSQ:	0	;SQUARE ITS MOVING TO
TSSW:	-1	;-1 NORMAL 0 OR > CLOBBERED
TPSW:	0	;-1 IF DESIRED MOVE IN PROGRESS
TRCSW1:	0	;0 TRACING P MOVE GEN (TACTICAL) 1 STATEV 2 AFTER HACK 3 P.M.G. (POSITIONAL)
TRSAC:	0	;AC RESULTS BEING SUMMED IN (FOR UUOH HACKER)

TPCHL==200
TPATCH:	BLOCK TPCHL	;SPACE FOR PATCHES TRACE PUTS IN

TUUT:	MOVEI←-27.	;UUO 4
	ADDI←-27.
	SUBI←-27.
	MOVE←-27.
	ADD←-27.
	SUB←-27.

LTUUT==.-TUUT


ATRTT1:	-LTRT,,
	-LSTRT,,
	-LSTRT,,
	-LPTRT,,

ATRTT2:	SETZ TRT(T1)	;4.9 INSERT P.M.G. PATCHES ELSE STATEV PATCHES
	STRT(T1)
	STRT(T1)
	SETZ PTRT(T1)

ATRTT3:	TRT(C)
	STRT(C)
	STRT(C)
	PTRT(C)

ATSAC:	R	;AC RESULTS BEING SUMMED IN
	R
	R
	W

STINI:	PUSHJ P,CORCMP	;COMPUTE WPAS, BPAS FOR ALL SQS
	PUSHJ P,CDVLV
	MOVEM S,WTDLVL
	MOVEM T1,BTDLVL
	SUB S,T1
	MOVEM S,PDVLV
	CLEARM CPCDVL
	PUSHJ P,STBCC
	MOVEM T1,CTVLVW
	MOVEM W,CTVLVB
	SUB T1,W
	MOVEM T1,CTVLVN
	MOVE T,[-LLMGPL,,LMGPDL-1]
	CLEARM PMV+1
	MOVE A,[PMV+1,,PMV+2]
	BLT A,PMV+NPC+1-1
	PUSHJ P,CTMAV	;COMPUTE PMV ARY
	PUSHJ P,MVNCC	;ADD IT UP
	MOVEM T1,CTMLVW
	MOVEM W,CTMLVB
	SUB T1,W
	MOVEM T1,CTMLVN
	CLEARM CPCMVL
	PUSHJ P,EKSF
	MOVE S,KSAEXP
	MOVEM S,PWKSF
	MOVE S,KSAEXP+1
	MOVEM S,PBKSF
	POPJ P,

;;MISC1
IFE DECTS,[
TIMIN:	CLEARM TANS
	SETOM TIMNF1	;TYPE IN TIME IN FORM H:M:S.T

TIM1:	MOVEI C,0
TIM2:	PUSHJ P,RCHA
	CAIN A,":
	JRST TIM5
	CAIN A,".
	JRST TIM3
	CAIL A,"0
	CAILE A,"9
	JRST TIM4
	IMULI C,10.
	ADDI C,-"0(A)
	JRST TIM2

TIM4:	ADDB C,TANS
	POPJ P,

TIM5:	AOSN TIMNF1
	IMULI C,60.
	IMULI C,60.
TIM3:	IMULI C,10.
	ADDM C,TANS
	JRST TIM1

TANS:	0
TIMNF1:	0

ASETCL:	PUSHJ P,RCHA
	MOVEI T1,0
	CAIN A,"B
	MOVEI T1,BCLOCK
	CAIN A,"W
	MOVEI T1,WCLOCK
	JUMPE T1,GERR
	PUSH P,T1
	PUSHJ P,TIMIN
	POP P,T1
	MOVEM C,(T1)
	JRST PSRET

]

IFN DSPLY,[
DISPG:	MOVEI B,DISAD
	JRST .+2
]
APG:	MOVE B,PNTS	;OUTPUT GAME SO FAR
	CLEARM PMRDF
APG6:	SETZB T, PGMCNT	;T IS LINE POS. INDICATOR
IFE DEC,CAIE B,PILPT
	CAIN B,PPA
	PUSHJ P,FORMF
	PUSHJ P,DCRR
	MOVEI S,GAME-1
APG5:	SKIPL QTF
	CAMN S,GAMP
	JRST DCRR
	LDB I,[420100,,1(S)]
	LDB A,[MPO,,1(S)]
	JUMPE A,PGPUT
APG10:	XCT PGPOS1(I)
	SOUT [ASCIZ /SIDE W
/]
	SETZM T
APG8:	JUMPN T,APG4
	MOVEI A,-GAME+3(S)
	LSH A,-1
	PUSHJ P,DPT
	SKIPN DPTNC
	PUSHJ P,DSPACE
APG3:	PUSHJ P,DSPACE
	JUMPE I,APG4
	SOUT [ASCIZ /SIDE B/]
	SETOM T
	SKIPE PMRDF
	JRST APG9
	MOVEI D,7
	PUSHJ P,DSPACE
	SOJGE D,.-1
	JRST APG4
APG9:	PUSHJ P,DTAB
APG4:	MOVE C,1(S)
	PUSHJ P,PMOVE
	JUMPN T, APG2
	SETOM T
	SKIPE PMRDF
	AOJA S,APG7
	MOVE D,SPNDD
	PUSHJ P,DSPACE
	SOJGE D,.-1
	AOJA S,APG1

APG2:	PUSHJ P,DCRR
	SETZM T
	AOJA S,APG5

APG7:	PUSHJ P,DTAB
APG1:	JRST APG5

PGPUT:	SKIPN C,1(S)
	AOJA S,APG5
	TRNN C,7
	JRST PGPUT2
	TRNN C,4
	JRST APG10
PGPUT2:	CAILE S,GAME	;???
	JRST PGPUT1
	CAIL S,GAME
	SKIPE (S)
	SOUT [ASCIZ /CLEAR
/]
PGPUT1:	SKIPE T
	PUSHJ P,DCRR
	SOUT [ASCIZ /PUT /]
	LDB A,[MPC,,C]
	LDB A,[PTID,,PIECE(A)]
	SKIPE I
	ADDI A,6
	SOUT TXTB(A)
	PUSHJ P,DSPACE
	LDB A,[MPTO,,C]
	MOVEI I,0	;SQUARE FROM WHITES SIDE
	PUSHJ P,SQOUT
	JRST APG2

PGMCNT:	0	;PLY NUMBER OF MOVE BEING PRINTED IF KNOWN ELSE -1

PGPOS1:	JUMPE T,APG8
	JRST APG8

EPMOVE:	SETOM PGMCNT
EPMOV1:	SETZM PMRDF
PMOVE:	SKIPL PGMCNT
	AOS PGMCNT
	MOVEI A,2
	MOVEM A,SPNDD
	LDB I,[420100,,C]
	TRNE C,7
	JRST PMOVE1
PMOVE5:	PUSHJ P,PMOVE6
PMOVE9:	SKIPN PMRDF
	TRNN C,CHKBT
	POPJ P,
	SOS SPNDD
	MOVEI A,"+
	JRST (B)

PMOVE6:	LDB A,[MPC,,C]
	PUSHJ P,PCOUTP
	PUSHJ P,DSLASH
	LDB A,[MPO,,C]
	PUSHJ P,SQOUT
	JUMPL C,PMOVE2
	REPEAT 2,AOS SPNDD
	MOVEI A,"-
	PUSHJ P,(B)
PMOVE3:	LDB A,[MPTO,,C]
	JRST SQOUT

PMOVE2:	MOVEI A,"*
	PUSHJ P,(B)
	LDB A,[MPTK,,C]
	PUSHJ P,PCOUTP
PMV2B:	PUSHJ P,DSLASH
	JRST PMOVE3

PMOVE1:	LDB D,[300,,C]
	CAILE D,2
	JRST PMOVE4
	SKIPN PGMCNT
	SOUT TXSIDE(I)
	SOUT TYPMT-1(D)
	MOVE A,TYPMT2-1(D)
	ADDM A,SPNDD
	JRST PMOVE9

PMOVE4:	CAIN D,3
	JRST PMOVE7
	PUSHJ P,PMOVE6
	SOUT  PROTXT-4(D)
PMOVE8:	REPEAT 2,SOS SPNDD
	JRST PMOVE9

	ASCIZ / EP/
PROTXT:	ASCIZ /=Q/
	ASCIZ /=R/
	ASCIZ /=B/
	ASCIZ /=N/

PMOVE7:	MOVNI A,1
	SKIPE PMRDF
	DPB A,[MPTK,,C]
	PUSHJ P,PMOVE6
	SKIPE PMRDF
	POPJ P,
	MOVE A,[35200536]
IFN DSPLY,[
	CAIN B,DISAD
	PUSHJ P,DISSIX
	CAIE B,DISAD
]
	SOUT [ASCII /EP!/]
	JRST PMOVE8

SPNDD:	0

PMRDF:	0	;1 OUTPUT IN FORM READABLE BACK

TXSIDE:	ASCII /W !/
	ASCII /B !/
;0 ALL PCS
;1 -1
;2 1ST THING TYPED
;3 2ND THING TYPED
;PSTBM PMOVING ORGL PTAKEN DESTIN

DEFINE PSTBM A,B,C,D
	A←11+B←6+C←3+D
TERMIN

PMI==110300
SMI==60300
DPMI==30300
DSMI==300

PSTB:	PSTBM 0,2,0,3	;SQ SQ
	PSTBM 0,2,3,1	;SQ PC
	PSTBM 2,1,0,3	;PC SQ
	PSTBM 2,1,3,1	;PC PC
	PSTBM 2,3,0,4	;PC SQ SQ
	PSTBM 2,3,4,1	;PC SQ PC
	PSTBM 2,0,3,4	;PC PC SQ
	-1	;PC PC PC
	-1	;PC SQ SQ SQ
	-1	;PC SQ SQ PC
	PSTBM 2,3,4,5	;PC SQ PC SQ

	REPEAT 17-<.-PSTB>,-1


;;TTY
IFE TS+DECTS,[
IFE DEC,[
TTYBRK:	0
	MOVEM A,TTYA
	MOVEM B,TTYB
	MOVEM C,TTYC
	MOVEI B,1
TTYB1:	CONO TTY,@TTYLT(B)
	CONSO TTY,40
	JRST TTYB2
	DATAI TTY,A
	ANDI A,177
	SKIPN HEAR
	JUMPN B,TTYB2
	CAIN A,↑Z
	MOVEM B,DEAF
	SKIPE DEAF
	JUMPE B,TTYB2
	MOVEM B,WHOTYP
	CAIN A,"[
	SETOM COMCNT
	SKIPN COMCNT
	MOVEM A,TYIMP
	CAIN A,"]
	CLEARM COMCNT
	MOVEM A,TTYEC(B)
	MOVEM A,@TTYECD(B)
	AOSN TTYON
	CONO TTY,@TTYST
	AOSN TTYON+1
	CONO TTY,@TTYST+1
	CONO TTY,@TTYLT(B)
TTYB2:	CONSO TTY,10
	JRST TTYB3
	MOVEI A,0
	MOVE C,[-4,,SPECF]
	HRRM B,TTYMOD
TTYMOD:	EXCH A,.(C)
	JUMPN A,TTYB4
	AOS C
	AOBJN C,.-3
	CONO TTY,200+TTYCHN
	SETOM TTYON(B)
TTYB3:	SOJGE B,TTYB1
	MOVE C,TTYC
	MOVE B,TTYB
	MOVE A,TTYA
	JRST 12,@TTYBRK


]

IFN DEC,[	
TTYBRK:	0
	MOVEM A,TTYA
	MOVEM B,TTYB
	MOVEM C,TTYC
	CONSO TTY,40
	JRST TTYB2
	DATAI TTY,A
	ANDI A,177
	CAIN A,"[
	SETOM COMCNT
	SKIPN COMCNT
	MOVEM A,TYIMP
	CAIN A,"]
	CLEARM COMCNT
	MOVEM A,ECHOC
	AOSN TTYON
	CONO TTY,10+TTYCHN

TTYB2:	CONSO TTY,10
	JRST TTYB3
	MOVSI B,-2
	MOVEI A,0

TTYL:	EXCH A,SPECF(B)
	JUMPN A,TTYB4
	AOBJN B,TTYL
	CONO TTY,200+TTYCHN
	SETOM TTYON
TTYB3:	MOVE C,TTYC
	MOVE B,TTYB
	MOVE A,TTYA
	JRST 12,@TTYBRK

]

TTYB4:	ANDI A,177
	CAIL A,40
	JRST TYOB5
	CAIL A,↑I
	CAILE A,↑M
	CAIN A,↑G
	JRST TYOB5
	TRO A,100
	MOVEM A,SPECF(B)
	MOVEI A,"↑
TYOB5:	MOVEM B,TTYBS2
	MOVE B,A	;COMPUTE PARITY
	IMULI B,200401
	AND B,[11111111]
	IMUL B,[11111111]
	TLNE B,10
	TRO A,200
	MOVE B,TTYBS2
	DATAO TTY,A
	TRZ A,200

IFE  DEC,[
	CAMN C,[-3,,TYOMP]
	JRST TTYB3
]
IFN DEC,[
	TRNE B,-1
	JRST TTYB3
]

	CAIN A,↑G
	SETOM QTF
IFN UTAPE,[
	CAIN A,↑S
	CLEARM UREADF
]
	SUBI A,3
	CAIN A,12
	MOVEM A,SPECF(B)	;[	HA HA
	SUBI A,"]-20
	CAIN A,15
	MOVEM A,SPECF(B)
	JRST TTYB3
	
TTYBS2:	0
]CRR:	MOVEI A,15
	PUSHJ P,TYO
	MOVEI A,12

TYO:
IFN UTAPE,[	SKIPGE BOOKF1
	CLEARM UREADF
]
	SKIPE WALLP
	PUSHJ P,PILPT

IFE TS+DECTS,[
IFE DEC,[
	PUSH P,B
	MOVEI B,1
TYO3:	SKIPE TYOMP(B)
	JRST .-1
	MOVEM A,TYOMP(B)
	AOSN TTYON(B)
	CONO TTY,@TTYST(B)
	SOJGE B,TYO3
	POP P,B
	POPJ P,

]

IFN DEC,[
	SKIPE TYOMP
	JRST .-1
	MOVEM A,TYOMP
	AOSN TTYON
	CONO TTY,10+TTYCHN
	POPJ P,
]
]

IFN TS,[	
TYO1:	SKIPGE TTYOFF
	JRST TYO1C
TYO1B:	.IOT TYOC,A
	SKIPL AUXTTS
	.IOT AUXTYO,A
TYO1C:	CAIL A,40
	AOS CRPOS
	CAIN A,15
	CLEARM CRPOS
	CAIE A,11
	POPJ P,
	PUSH P,A
TYO1A:	AOS A,CRPOS
	TRNN A,7
	JRST POPAJ
	JRST TYO1A
]

IFN DECTS,[
	IDPB A,TYOO+1
	OUTPUT TYOC,
	POPJ P,
]

RCHA:	MOVEI A,0
	SKIPL QTF
	PUSHJ P,TYI
	CAIN A,":
	SOS TRCOLF
	AOSN QTF
	JRST TYIQ
	CAIN A,↑G
	JRST RCHA
	POPJ P,
TYI:
RCH:	IFN UTAPE,[
	SKIPGE UREADF
	JRST TYIUT
]
IFE TS+DECTS,[	SKIPN A,TYIMP
	JRST TYI
	CLEARM TYIMP
]
IFN TS,	IOT TYIC,A
	SKIPL AUXTTS
	.IOT AUXTYO,A
IFN DECTS,[
	SOSG TYII+2
	INPUT TYIC,
	ILDB A,TYII+1
]
	CAIGE A,140
	JRST .+3
	CAIE A,177
	SUBI A,40

CHARIN:	SKIPE WALLP
	PUSHJ P,LPTRA
IFN DECTS,JUMPE A,TYI
IFN TS+DECTS,[
	CAIN A,"[
	SETOM COMMENT
	CAIN A,"]
	CLEARM COMMENT
	SKIPGE COMMENT
	JRST TYI
]
	CAIN A,↑D
	JRST DDTA
	CAIN A,↑E
	JRST EHACK1
	CAIE A,↑F
	CAIN A,↑X
	JRST TYI
IFN UTAPE,[
	CAIN A,↑Q
	JRST TYISUT
	CAIN A,↑S
	JRST TYI
]
	CAIN A,↑U
	JRST HACK2
	POPJ P,

ASTPIN:	CLEARM UREADF
	POPJ P,

ASKIP:	PUSHJ P,GETNUM
	MOVEM C,ASKPT
	SETOM UREADF
ASKP1:	PUSHJ P,URED
	ERRTTY [ASCIZ /EOF?/]
	CAIN A,↑C
	JRST .-2
	CAIE A,"[
	JRST ASKP1
	PUSHJ P,GETNUM
	CAME C,ASKPT
	JRST ASKP1
	CLEARM UREADF
	POPJ P,

ASKPT:	0

IFN TS+DECTS,COMMENT:	0

EHACK1:	PUSHJ P,HACK1
	JRST MNLP

DDTA:	IFE DEC,[PUSHJ P,LPTWAT
	HRROS DDT-1
	SKIPGE TTYON
	SKIPL TTYON+1
	JRST .-2
	MOVE A,WHOTYP
	CONO TTY,@TTYLT(A)
]

IFN DEC-TS-DECTS,[
	SKIPL TTYON
	JRST .-1
]
IFE TS,	JRST DDT
IFN TS,[.VALUE
	JRST TYI
]

TYIQ:	PTTY [ASCII /QUIT!/]
	JRST PNORM


IFN UTAPE,[
TYISUT:	SETOM UREADF
TYIUT:	PUSHJ P,URED"
	JRST EOFUT
	CAIN A,↑C
	JRST EOFUT
	JRST CHARIN

EOFUT:	CLEARM UREADF
	PUSHJ P,CRR
	PUSHJ P,LATYO
	JRST TYI

UREADF:	0
]

AUXTTS:	-1
AUXTTY:	PUSHJ P,GETNUM
	JUMPL C,AUXTT1
	MOVE D,C
	DPB D,[300,,AUXO]
	LSH D,-3
	DPB D,[60300,,AUXO]
	.OPEN AUXTYO,AUXO
	JRST AUXL
	MOVEM C,AUXTTS
	POPJ P,

AUXL:	MOVEI B,TYO
	SETOM AUXTTS
	SOUT [ASCIZ /LOSE/]
	POPJ P,

AUXTT1:	SETOM AUXTTS
	.CLOSE AUXTYO,
	POPJ P,


AUXO:	SIXBIT /  !T00/
	SIXBIT /AUX/
	SIXBIT /OUT/

IFN TS,[
URED:	.IOT UTYIC,A
	SKIPL A
	AOS (P)
	POPJ P,

UREDB:	.IOT UTYIC,A
	POPJ P,

ITYON:	CLEARB B,TTYOFF
	JRST ITYOF1

ITYOF:	SETOB B,TTYOFF
ITYOF1:	MOVE B,ITYMT+1(B)
ITYOF2:	ILDB A,B
	JUMPE A,INT1
	PUSHJ P,TYO1B
	JRST ITYOF2

ITYMT:	440700,,[ASCIZ /TTY OFF
/]
	440700,,[ASCIZ /TTY ON
/]

INT2:	MOVEI B,TYO
	ISOUT [.ASCII ?PDLOV PC=*O!INT+1?]
	.VALUE

]
IFN DECTS,[
URED:	SOSLE UTYII+2
	JRST URED1
	IN UTYIC,
	JRST URED1
	POPJ P,

URED1:	ILDB A,UTYII+1
	AOS (P)
	POPJ P,
]

IFE TS+DECTS,[
 UREDB:	PUSHJ P, .URED"
	JFCL
	POPJ P,
]

IFE TS,[
IFE DEC,[
IRPS A,,SPECF TYOMP TTYEC TTYECO
A:	BLOCK 2
TERMIN

AUXTYN==1

TTYON:	-1
	-1
TTYST:	500010+TTYCHN
	500010+AUXTYN←12.+TTYCHN
TTYLT:	500000+TTYCHN
	500000+AUXTYN←12.+TTYCHN
TTYECD:	TTYECO+1
	TTYECO

IRPS A,,TTYA TTYB TTYC TYIMP QTF DEAF WHOTYP COMCNT HEAR
A:	BLOCK 1
TERMIN

]
IFN DEC,[
TYIMP:	0
SPECF:
ECHOC:	0
TYOMP:	0	;MUST BE ECHOC+1
TTYON:	-1
TTYA:	0
TTYB:	0
TTYC:	0
COMCNT:	0
QTF:	0
]]

LPTRA:	PUSHJ P,PILPT
	SUBI A,3
	CAIN A,12
	PUSHJ P,PILPT
	ADDI A,3
	POPJ P,

IFN TS,QTF:	0

;;MISC2
STFPNT:	MMSAVAC
	MOVE W,CATCSA+W
	MOVEM B,ST